Hi guys, one question about faceting. Let's say we...
# community-help
j
Hi guys, one question about faceting. Let's say we have a collection with, id, product name, category, And you return documents and facet the categories. so far so good. Then the user selects the category and you submit an filter category:shoes. In the result facet, you get only one category. But for the UI i want to be able to see all the categories, to select more than only shoes. How can i achieve that? Is the only solution mutlysearch and create multiple requests, and combine the results? There could be a problem, because i have a lot of attributes too, and i would need to do many requests to the API to achive multi attribute selection. Thank you.
k
Check the song search demo here: https://songs-search.typesense.org/ You can see how it makes a bunch of requests to populate all those facets. If you use the instant search library, you get this out of the box. But yes, if you have too many attributes to facet on, it's bit tricky to get it right.
👍 1
j
Ok i've checked the sample. So yes, at the end, you have to create multiple requests/searches to get what you want. I was thinking if there is any similar way like on SOLR that you can tag the filters, and exclude them on each of the facet. Not a problem at all, i think i got all the answer. Thank you.
k
Can you post how you would construct a query for this on SOLR?
j
Huh that was some months ago I've tried this. But i found the sample online: https://www.codexpedia.com/solr/faceted-search-and-filter-exclusion-in-solr/ First you create filter query and set a tag. in the example tag=mf, then on the faceting level of that particular field you say, that you want to exclude that tag: facet.field={!ex=mf}manufacturer Then in the code, you can modify the results and say which of the facet values are "selected" (based on the request you've send) and which are not.