Prioritizing Search Mechanisms in Typesense

TLDR Roman asked if there was a way to prioritize searches in 'foo' over 'bar' in Typesense. Jason clarified that only sequential searches would satisfy this. Yoann suggested batching the requests.

Photo of Roman
Roman
Tue, 19 Sep 2023 15:32:22 UTC

Hi all, say I have `query_by=foo,bar`, is there a way to first evaluate search against `foo` *only* first and if nothing is found there (and only then), query `bar` field?

Photo of Jason
Jason
Tue, 19 Sep 2023 15:41:31 UTC

This is how Typesense's default search mechanism works by default... Fields mentioned in query_by are used in priority order

Photo of Roman
Roman
Tue, 19 Sep 2023 16:10:27 UTC

I mean not include stuff matched by `bar` at all if there are any matches in `foo`

Photo of Jason
Jason
Tue, 19 Sep 2023 16:13:26 UTC

That's not possible to do out of the box. So you would have to first send a search query with just `query_by=foo` and then depending on the results, conditionally send another search request for `query_by=bar`

Photo of Roman
Roman
Tue, 19 Sep 2023 16:14:18 UTC

I see, thank you

Photo of Yoann
Yoann
Thu, 21 Sep 2023 07:49:04 UTC

You could probably batch the two requests in a multi-search