I am getting aggregations for filter but I dont know how to do next step when filter is selected on the page. for example If red color is selected. should I use a filter term query instead of multi-match query or should I extend above multi-match query with filters? Not sure how to achieve this. I appreciate if somebody can shed me some lights ? and short example will be lovely.
what I am confused about is aggregation filters? are those filters just narrowing down returned aggregations? what is the purpose of those filters? if you can give me a simple example, I appreciate.
Exactly. Aggregation filters should be used when a filter should ONLY apply to aggregations. If a filter should apply to both aggregations and the top hits (or if you do not care about the top hits), then it should be put in the query element. Given what you are trying to do, you should probably be doing something like this:
There are not many use-cases for aggregation filters. One example would be that your users are looking for x OR y OR z and you want to tell them how many documents have 2 out of 3 terms. You would put a regular bool query in the query part that will match all documents that contain either term, and then you would have an aggregation filter with a bool query with those 3 terms and a min_should_match of 2 so that elasticsearch will compute how many docs contain 2 of the queried terms or more.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.