Hello everyone, I have a very simple question. 1. ...
# community-help
a
Hello everyone, I have a very simple question. 1. Is there a way to pin a facet in cases like a. In general case, i want facet to come on top if its in filter response. b. if i am filtering response and the pinning facet is not in it and still i want the facet to come on top . So can anyone please help me with it. i would be very grateful of them.πŸ™
k
Can you please give an example?
a
Right now, I’m fetching a list of suppliers based on how many matching parts they have from a customer’s order. So basically, suppliers with the most matched parts are shown at the top. Example: 1. ABC – 15 parts matched βœ… 2. DEF – 10 parts matched βœ… 3. XYZ – 0 parts matched ❌ But here's what I want to do differently: πŸ‘‰ I want a specific supplier, say
"XYZ"
, to always show up at the top, even if they have 0 matched parts. Why? XYZ is a preferred/internal supplier, so I want to give them priority visibility β€” even when they don’t have any parts for this particular order. 1. XYZ – 0 parts matched πŸ”Ό (forced to top) 2. ABC – 15 parts matched 3. DEF – 10 parts matched
Consider this only for Facet primarily.
i want this functionality on facet
k
Ok, so while the facets are sorted by count, you still want some facets (preferred supplier) to show up on top even if they have no / now counts?
a
yes exactly
k
We actually have a way to sort facets on the value of a sibling filed. E.g. from our documentation:
Copy code
You can also sort facets on the value of a sibling field like this: recipe.name(sort_by: recipe.calories:asc)
Here, the
recipe
is an object and
name
and
calories
are field inside the object. While faceting on
receipe.name
you can sort on
calories
(useful in diet apps). However, I am not sure how we break the tie if 2 facets have the same calorie values. I suspect we could allow falling back to counts on tie. If we do this, you can set a
preferred
boolean flag and use this to sort those preferred suppliers to the top.
a
we are using React InstantSearch library + instant typesense adapter. and we are using useRefinement list to fetch the facets. can u guide how to implement the same example. The FacetAttribute is
Copy code
[supplierInfo]
Because ur example i am getting that i can sort on particular Object value of facet, but cant pin. So i have a question if i put "XYZ" preferred value to 100. and other to 0. so will it come on top and remaining will come based on count sort, preferred 0 wont affect the earlier responses?
k
Currently, I'm not sure if we fallback to the count when prefferred: 0 -- it's a bit late here, but I have to check and get back to you. If that works, then we have to look into adding support to the react instantsearch for this feature.
a
Yeahh sure, i would be glad if we are bale to solve this problem. and i am trying myself too
😁
k
If you can use the API directly, just try sending the facet by in the format I have explained above.
But I suspect we don't do tie breaking on actual counts yet.
a
Yes i tried it but its not working for me
i am getting the responses in the required order but not the facets
k
We are going to make a patch to make this work. Will give you a patched build in a couple of days.
a
Thanks a lot @Kishore Nallan to taking our request, and i would be very happy if u can help us to make this work.πŸ™Œ