#community-help

Running Multiple Facet Queries Simultaneously

TLDR Stefan asked about running multiple facet queries, Kishore Nallan suggested using multi_search with a facet_query for each facet as a workaround.

Powered by Struct AI
Mar 31, 2022 (19 months ago)
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
11:41 AM
Is there a way to run mutliple facet queries for multiple facets?
As in, I can specify: "facet_by: "category,container,x,y,z"
But I can only have one facet_query: "category:shoe" as far as I see. Doing "category:shoe,cotainer:can". Is that correct?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
11:49 AM
There's no way to run multiple facet queries. Mostly because in the user interface, you tend to use it primarily for filtering within returned facets, and that's usually done on any one field only, and not on multiple fields at the same time.
Stefan
Photo of md5-d6c265b4792dbf0a1d6ae378f39d8736
Stefan
11:53 AM
True, but I would like to implement the following use case:
I have a search bar and as the user types, I'd like to search for products with the search term in it.

At the same time I'd like to do a facet_query to suggest filters, for example someone searches for "vitam", I would like to suggest "vitamin c" as a filter option.

Is there a better way to implement this?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:00 PM
You can always use multi_search with N facet_queries, one for each facet. That's a work around, but eventually, yes we could support having multiple facet queries in a comma separated list as you've given above.