Aggregation Counts on Independent Variables


#1

I am attempting to figure out the type of aggregation(s) I would need to implement specific UI behavior with aggregation counts. For example, if I have real estate listings with 3 fields - bedrooms, bathrooms, and building type - I would like to have a UI return counts based on each field, with the field being searched on being the independent variable where its count is not modified, but the other fields are. I've included a pastie of what the select-flow would look like:

http://pastie.org/10253332

In other words, if I click for a specific field value in bedrooms, bedroom aggregation counts would not update, but bathrooms and building type do. If I click on a specific value for bathrooms, bathroom aggregation counts would not update, but bedrooms and building type do. If I uncheck a value for bathrooms, once again bathroom aggregation counts would not update, but bedroom and building type do.

Currently I am attempting to keep track of which variable is the independent (checked/unchecked) field via passing in a parameter, and based on that, getting two aggregations - one where everything is filtered based on whatever has been checked, and another aggregation where it has all filtered sans the independent variable. On the UI side I'm using logic to pull in the aggregation count for each field based on the independent variable.

Is there an Elastic Search Best Practices way of performing such a faceted search? I was hoping that being able to perform such aggregations based on an independent variable would have a best practices way to do so. Is there also a way for elastic search to detect the independent variable without having it be explicitly declared?


(Mark Harwood) #2

If I've interpreted your question correctly this is the same problem/solution: https://github.com/elastic/elasticsearch/pull/7020#issuecomment-53087546


(system) #3