- Java Transport Client (deprecated): other versions:
- Preface
- Maven Repository
- Dealing with JAR dependency conflicts
- Embedding jar with dependencies
- Deploying in JBoss EAP6 module
- Client
- Document APIs
- Search API
- Count API
- Aggregations
- Percolate API
- Query DSL
- Indexed Scripts API
- Java API Administration
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Aggregations
editAggregations
editElasticsearch provides a full Java API to play with aggregations. See the Aggregations guide.
Use the factory for aggregation builders (AggregationBuilders
) and add each aggregation
you want to compute when querying and add it to your search request:
SearchResponse sr = node.client().prepareSearch() .setQuery( /* your query */ ) .addAggregation( /* add an aggregation */ ) .execute().actionGet();
Note that you can add more than one aggregation. See Search Java API for details.
To build aggregation requests, use AggregationBuilders
helpers. Just import them
in your class:
import org.elasticsearch.search.aggregations.AggregationBuilders;
Was this helpful?
Thank you for your feedback.