i'm positive this has been asked before, maybe her...
# community-help
r
i'm positive this has been asked before, maybe here or on github; so maybe someone can point me in the right direction: i have several facets which we display using algolia instantsearch refinement widgets. i want to 'tweak' those lists by giving certain values priority over others, even though they have less hits (or some have a lot, but are less important)
f
https://typesense.org/docs/27.1/api/search.html#sorting-facet-values This is the documentation for sorting facet values, to apply them to instantsearch, you'd add them as
additionalParameters
in the adapter's constructor
r
no, not that. it's more like, in this screenshot, i want 'Bestelling wordt verwerkt' up top cause it's the most important/most searched for
but right now it's under 'show more/less' because it has a very low amount of hits/related documents
f
Maybe set it up as a nested field with a sibling value of
status.popularity
, and sort based on that? Keeping track of the popularity of the status is dependent on you though. You can use Analytics Rules with a custom event type to send out the event each time a user uses that facet, or just keep track of it manually yourself
r
no i just want it hardcoded
f
Maybe use
facet_query
under the hood and after you get the result for it, populate the UI and run it normally afterwards? I'm not sure how performant that would be, or even if it's at all possible using Instantsearch's widgets.
r
solved it using
Copy code
sortBy: (a, b) => {
  // this status always comes first
  if (a.name === 'Bestelling wordt verwerkt') {
    return -1
  }

  // else defer to count, starting from highest first
  return b.count - a.count
}
in the
refinementList
widget properties
now i'm trying to determine why the
toggleRefinement
widget is showing the wrong count
it should show 9, not 166 😞
cause only 9 match the value that i am using for the
on
state (which is
false
in our case, not
true
)
ah, found it
thanks for 🦆 😅
f
```sortBy: (a, b) => {
// this status always comes first
if (a.name === 'Bestelling wordt verwerkt') {
return -1
}
// else defer to count, starting from highest first
return b.count - a.count
}```
This happens on the client. It may have performance degradation as more facet values are introduced, as it will have to hit the max facet values OR may not show it at all, if it passes the max facet values number
r
yeah, but that's fine. the amount of facet values is fixed. only the amount of documents changes.
f
If it's static then yeah, works just fine!