But what if you would like to filter just the aggregation results? Imagine we are building the search page for our car dealership. We want to display search results according to what the user searches for. But we also want to enrich the page by including the average price of cars (matching the search) that were sold in the last month.
We can’t use simple scoping here, since there are two different criteria. The
search results must match
ford, but the aggregation results must match
sold > now - 1M.
Here is the resulting query:
filter bucket operates like any other bucket, you are free to nest
other buckets and metrics inside. All nested components will "inherit" the filter.
This allows you to filter selective portions of the aggregation as required.