Learn how to summarize or "aggregate" data with cbElasticsearch
In some cases, you aren't interested in searching documents as you are in retrieving specific information stored within each document. It is for such a purpose that Elasticsearch provides the ability to aggregate, or summarize, index data.
Creating an Aggregation
cbElasticsearch's SearchBuilder provides an aggregation() method for simple aggregation definitions:
To run the query and retrieve aggregations, call searchBuilder.execute() followed by getAggregations(). getAggregations() will return a key/value struct where the key is your provided aggregation name: