Elasticsearch - exclude filter from aggregations Elasticsearch - exclude filter from aggregations elasticsearch elasticsearch

Elasticsearch - exclude filter from aggregations


One way to approach this problem is to use post_filter as described here.

It might be performance concern, so if it doesn't fit your SLA there is alternative approach using global bucket and described here.


You can use post_filter for elasticsearch. Post filter excludes the scope of the filters from the aggregations and is perfect to build an eCommerce search for drilled down aggregations count on filters

you can build a query like the following

{    "aggs": {        "agent_id": {            "terms": {                "field": "agent_id",                "size": 10            }        }    },    "post_filter": {        "bool": {            "terms": {                "agent_id": [                    "58becc297513311ad81577eb"                ]            }        }    }}

Thanks