IMPORTANT: No additional bug fixes or documentation updates will be released for this version. For the latest information, see the current release documentation.
Elasticsearch 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:
Intro to Kibana
ELK for Logs & Metrics