title: Getting only aggregations results in elasticsearch
body: <p>I am doing aggregation like this:</p>
  <pre><code>  {
     &quot;size&quot;:0,
     &quot;aggs&quot;:
      {
        &quot;my_aggs&quot;:
        {
           &quot;terms&quot;:
            {
              &quot;field&quot;:&quot;my_field&quot;
            }
        }
     }
  }
  </code></pre>
  <p>I want to get only the aggregation result. So when I set <code>size=0</code> like below, it gives error-later learned this is for how many results I want(aggregations). So, <strong>how can I achieve this to get only the aggregation results(no hits result docs)</strong></p>
  <pre><code>AbstractAggregationBuilder aggregationBuilder = AggregationBuilders
                  .terms(&quot;my_aggs&quot;)
                  .field(&quot;my_field&quot;)
                  .size(0) //how to set size for my purpose?
                  .order(BucketOrder.key(true));
  </code></pre>
  <p>Moreover, <strong>If I get thousands of aggregation results, does this query return all of them? or apply to its default 10 size? If not, how do know how many should I set size of aggregation result.</strong><br><br><br>
  <strong>Edit</strong> I am adding my aggregation like this:</p>
  <pre><code> SearchQuery searchQuery = new NativeSearchQueryBuilder()
                  .withIndices(indexName)
                  .withTypes(typeName)
                  .withQuery(boolQueryBuilder)
                  .addAggregation(aggregationBuilder)
                  .build();
  </code></pre>
  <p>Please help.</p>