The default return size for an aggregation result is 10 items, that is why you are only getting 10 results back. You will need to set the size
on the AggregationBuilders
object to a larger value in order to return more or all values in the bucket.
SearchResponse response = client.prepareSearch("index")
.setTypes("type")
.setQuery(QueryBuilders.matchAllQuery())
.addAggregation(AggregationBuilders.terms("TermsAggr")
.field("aggField").size(100))
.execute().actionGet();
If you always want to return all values, you can set size(0)
. However, you will need to upgrade to ES 1.1, as this was recently added to that release via Issue 4837.