#community-help

Prioritizing Results in Autocomplete Search

TLDR Sachyya and Digamber discuss issues with ordering of results for multi-collection auto-complete searches. Kishore Nallan suggests using a dynamic filtering feature but notes that behaviour might not be optimal if user input varies.

Powered by Struct AI
Apr 08, 2022 (19 months ago)
Sachyya
Photo of md5-3b78e17280dd19e5eca44e22ee940b76
Sachyya
10:29 AM
Does anybody know how to proritize the result from the first word than the second word in Autocomplete search?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:30 AM
👋 can you give an example so I can understand better?
Sachyya
Photo of md5-3b78e17280dd19e5eca44e22ee940b76
Sachyya
10:40 AM
For example:
we have results like
1. Adele
2. Bring Me the horizon
When I search "adele someone like me", it shows "Bring Me the Horizon". I want "Adele" to be shown.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
10:44 AM
Is there is a record with title "someone like me" in the dataset?
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
04:05 PM
Hi Kishore this is with a multi search use case
There are two collections Artists and Songs
the Artist is : Adele and the Song is Adele - Woman like me
When we type Adele Woman Like Me
The result for Adele does not show up / returned for Artist Adele
Rather we’re getting a different result - it almost seems like the last word is prioritized over the first.
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:12 PM
Just to confirm, you are querying two different collections or two different fields in the same collection?

In any case when Typesense does not find all tokens in the query, it tries to drop tokens from right to left and then left to right until results are found. This behavior might be resulting in the ordering you notice.
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
04:27 PM
we’re querying two different collections artists and songs
04:27
Digamber
04:27 PM
we really need to prioritize left to right cause artists name is presumed to be the first
04:27
Digamber
04:27 PM
or most priority
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
04:30 PM
In latest 0.23 RC you can use dynamic filtering feature in which you can define a rule for queries that begin with artist name where it will get converted into a filter clause directly. However, even then if other tokens don't match no results are going to be found.

We might have to parameterise this behavior but what if people put the artist last?
Digamber
Photo of md5-a0246423746b3b51425d05cfd9c494ae
Digamber
04:33 PM
you’re right - i need to think of this more too no problems with single collection but for multi search it’s something to think about