WARNING: Version 2.3 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Filter Aggregation
editFilter Aggregation
editDefines a single bucket of all the documents in the current document set context that match a specified filter. Often this will be used to narrow down the current aggregation context to a specific set of documents.
Example:
{ "aggs" : { "red_products" : { "filter" : { "term": { "color": "red" } }, "aggs" : { "avg_price" : { "avg" : { "field" : "price" } } } } } }
In the above example, we calculate the average price of all the products that are red.
Response:
{ ... "aggs" : { "red_products" : { "doc_count" : 100, "avg_price" : { "value" : 56.3 } } } }