#community-help

Customizing Count References and Range Boundaries in Instantsearch

TLDR Vishal asked how to change count references and implement range bounds in Instantsearch. Jason suggested custom widgets and setting up attributes during indexing for these tasks.

Powered by Struct AI
13
3mo
Solved
Join the chat
Jun 26, 2023 (3 months ago)
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
03:50 PM
For your demos I noticed that the counts are all consistent with the primary search term, in this case commits, is there a way to make the count reference something other than the primary search?
Image 1 for For your demos I noticed that the counts are all consistent with the primary search term, in this case commits, is there a way to make the count reference something other than the primary search?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:05 PM
If you’re using Instantsearch UI library, I don’t believe this is possible to do. But if you’re building your UI, then you can facet on any field as needed
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
04:07 PM
I'm using Instantsearch -- ok
04:27
Vishal
04:27 PM
do you know if you can easily range bound it?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:27 PM
May be there’s a way to build a custom widget to do that… and also make it a static bounded list if needed
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
04:28 PM
eg lets say you want the various sort choices to be ranges rather than values
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:28 PM
Ah that type of range… for that you would have to setup an attribute which defines the range in your dataset at indexing time
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
04:29 PM
ok -- can't bucketize in the ui layer?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:29 PM
No unfortunately
04:29
Jason
04:29 PM
For, eg in this demo: https://songs-search.typesense.org/?s%5Bquery%5D=Annie%27s%20song%20Denver

Notice how the release year shows up in the UI, and in the dataset (browser dev console network tab - look for multi_search). There’s both a Unix timestamp and also a release_decade
Vishal
Photo of md5-178450ab9171fe1c7eba3a5eb7e1a312
Vishal
04:30 PM
ahh
04:31
Vishal
04:31 PM
ok