In our new project, we were inspired by this article http://project-a.imtqy.com/on-site-search-design-patterns-for-e-commerce/#generic-faceted-search to execute our "facet" structure . And while it works for me, as described in the article, I ran into problems in getting it to work when selecting faces. I hope someone can give a hint about something to try, so I don’t need to redo all of our clusters into separate aggregation calculations again.
The problem is that we use a single aggregation to calculate all the “faces” at once, but when I add a filter (for example, checking the brand name), then it “deletes” all other brands when returning the aggregates. Basically, I want him to use this brand as a filter when calculating other aspects, but not when calculating brand aggregates. This is necessary so that the user can, for example, select several brands.
Looking at https://www.contorion.de/search/Metabo_Fein/ou1-ou2?q=Winkelschleifer&c=bovy (this is the site described in this article), I selected "Metabo" and "Fein", (Hersteller), and expanding the Hersteller menu, it shows all the manufacturers, not just the selected ones. Therefore, I know that this is possible, and I hope that someone has a hint on how to write aggregates / filters, so I get the "correct behavior of the ecommerce facets."
In products in ES, I have the following structure: (same as in the original article, although "C # ified" when naming)
"attributeStrings": [ { "facetName": "Property", "facetValue": "Organic" }, { "facetName": "Property", "facetValue": "Without parfume" }, { "facetName": "Brand", "facetValue": "Adidas" } ]
Thus, the above product has 2 attributes / facet groups - Property with two values ​​(organic, without perfume) and brand with 1 value (Adidas). Without any filters, I compute aggregates from the following query:
"aggs": { "agg_attr_strings_filter": { "filter": {}, "aggs": { "agg_attr_strings": { "nested": { "path": "attributeStrings" }, "aggs": { "attr_name": { "terms": { "field": "attributeStrings.facetName" }, "aggs": { "attr_value": { "terms": { "field": "attributeStrings.facetValue", "size": 1000, "order": [ { "_term": "asc" } ] } } } } } } } }
Now, if I select Property "Organic" and "Adidas", I will create the same aggregation, but with a filter, to apply these two restrictions (which would be bad ...):
"aggs": { "agg_attr_strings_filter": { "filter": { "bool": { "filter": [ { "nested": { "query": { "bool": { "filter": [ { "term": { "attributeStrings.facetName": { "value": "Property" } } }, { "terms": { "attributeStrings.facetValue": [ "Organic" ] } } ] } }, "path": "attributeStrings" } }, { "nested": { "query": { "bool": { "filter": [ { "term": { "attributeStrings.facetName": { "value": "Brand" } } }, { "terms": { "attributeStrings.facetValue": [ "Adidas" ] } } ] } }, "path": "attributeStrings" } } ] } }, "aggs": { "agg_attr_strings": { "nested": { "path": "attributeStrings" }, "aggs": { "attr_name": { "terms": { "field": "attributeStrings.facetName", }, "aggs": { "attr_value": { "terms": { "field": "attributeStrings.facetValue", "size": 1000, "order": [ { "_term": "asc" } ] } } } } } } } }
The only way I can see this model forward is to calculate the aggregation for each selected face and somehow combine the result. But it seems very difficult and peculiar defeat in the fact that this model has a model, as described in the article, so I hope that there will be a cleaner solution, and someone can give a hint about something to try.