#community-help

Configuring InstantSearch.js Parameters and Comparing Search Results

TLDR John is having difficulty configuring InstantSearch.js parameters. Jason suggested how to utilize facet_by and filter_by widgets and advised checking network for search parameters. They also asked John to open an issue on the unexpected need for manual _text_match addition.

Powered by Struct AI

2

Jun 01, 2021 (30 months ago)
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
04:40 PM
Hi, I am having a hard time configuring the my InstantSearch.js to reproduce this. Anyone could help me?
04:44
John
04:44 PM
Right now this is what I have:
additionalSearchParameters: {
    queryBy: 'categories,artname,artistname,color1,color2,tags,dimensions',
    sortBy: 'numsales:desc'
  },
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:03 PM
John Out of the parameters in the screenshot only query_by and include_fields can be directly configured via additionalSearchParameters in Instantsearch. This is because Instantsearch manages the other parameters internally through their widgets.

So to use facet_by and filter_by you want to use one of the refinement (or filter) widgets that Instantsearch offers. For sort_by, there's the sort widget - [here's](https://github.com/typesense/typesense-instantsearch-adapter/issues/9#issuecomment-710091167) how you configure it for Typesense. If you want to configure default params, have a look at the configure widget.

1

John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
05:27 PM
OK, thanks, and what about the
_text_match:desc

sortBy parameter? Is it an implicit one or do I need to put it in there as well?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:29 PM
It's implicitly added as the first sort_by parameter by Typesense
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
05:29 PM
OK, that's what I thought
11:23
John
11:23 PM
OK, here, I have another question Jason: what determines the results set is only, in fact, the queryBy and sortBy lines, right? Because at some point I had thought the Include Fields also were modifying the output...
11:25
John
11:25 PM
Now, what I am not understanding though is why I have different results on my website compared to the admin interface of https://cloud.typesense.org/
11:26
John
11:26 PM
On the Cloud, the results are much better, and I don't know why...
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:27 PM
It's most likely that all search parameters are not being included... If you look at the network tab in both the cloud console and your website as search requests are made, you'll be able to get the exact search parameters that are being sent to Typesense and see what the differences in parameters are
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
11:32 PM
OK perfect, I will compare!
11:38
John
11:38 PM
Comparison
On my website:
"sort_by": "numsales:desc",
On the cloud:
"sort_by": "numsales:desc,_text_match:desc",
11:38
John
11:38 PM
So it seems I need to add the _text_match manually?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:40 PM
Hmmm, _text_match should get added to the end automatically...
11:40
Jason
11:40 PM
Let's try that though
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
11:41 PM
Don't know why but it wasn't. I added it manually and it now works!
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:42 PM
Glad it works when you added it by hand! But this is different from expected behavior - it should automatically add _text_match at the end if it's not specified. Will take a look shortly

1

Jun 03, 2021 (30 months ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:25 AM
John Mind opening a github issue in the typesense repo with a minimal sample dataset reproducing the issue you saw, where "sort_by": "numsales:desc" and "sort_by": "numsales:desc,_text_match:desc" produced different results? Wasn't replicate it, so I'm wondering if there's something else that might be going on