Hello, I'm having an issue with facets and I'm won...
# community-help
h
Hello, I'm having an issue with facets and I'm wondering if what I'm looking for is possible: When filtering by a faceted field, I still want to be able to see the other facet options from this field. Filters from other fields should still apply. So for example: I have a collection of books with a
year
and
author
field. Faceting returns e.g.
[2020,2021,2022]
for the year. Is there a way to select books from 2020 and still have the other facet options available in the response? When I select 2020 I still want the author facets to be filtered by that query.
k
You're probably looking for this feature? https://github.com/typesense/typesense/issues/943 We've implemented this, and I can share a build with you tomorrow.
h
Not exactly, the facets are not objects but primitive types. But right now, when I filter by
year:2020
the facets in the response only include this year. I want the user to be able to see the other options as well
k
Ah got it, something like how it happens in this demo as you apply the facet filters? https://ecommerce-store.typesense.org/
h
@Kishore Nallan yes, that's exactly the behaviour I'm looking for!
unfortunately my project does not run on node so I'm not sure how to apply this. Is there a special filter flag to achieve this faceting behaviour?
k
We integrate with instantsearch.js JS library which gives you this behavior out of the box. See the demo app uses node, but the requests are made directly from frontend.
Otherwise, you will have to use multi_search end-point to make those queries. You can look at the network inspector tab to see the queries being made and figure out what you need to do.
h
Thank you, I will try that. It seems that I have to make multiple requests for this to work so currently there is no server side feature for this?
if I use multi_search it will not be multiple requests but still do multiple searches on the typesense server, I presume?
k
It will go as a single request but inside a multi search request you can have independent search queries
h
Thanks - I think I know what to do now