#community-help

Issues with Prefix Search and Sorting Results in Typesense

TLDR Pankaj asked about prefix search issues and sorting results in Typesense. Kishore Nallan explained prefix search limitations and suggested using text_match for sorting. Filtering with prefix searching isn't supported.

Powered by Struct AI

1

1

9
5mo
Solved
Join the chat
May 06, 2023 (5 months ago)
Pankaj
Photo of md5-6eb5a1ce5c2a902eaa7ed5dae82ed54b
Pankaj
08:38 AM
Hello, I've 2 questions.

1. Given the data like this

{
   "invoice_number": "inv123456",
   "company_name": "company name",
}

for query inv, I get expected result

<mark>inv</mark>123456

but for the query inv company, I get a match only for the company name, expected is to match both fields
am I missing something here?

2. We are doing multi search on 4 collections, whats the best to sort results for a combined array ? is text_match is enough for this?

Thank you 🙂
May 08, 2023 (5 months ago)
Pankaj
Photo of md5-6eb5a1ce5c2a902eaa7ed5dae82ed54b
Pankaj
05:48 AM
Any help would be appreciated Kishore Nallan Jason 🙏
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
05:49 AM
Typesense does prefix search only for the last word in the query. Since inv is the first word in the query inv company it won't match inv123456
05:49
Kishore Nallan
05:49 AM
For sorting, you can use the text match value in the text_match_info object associated with each it.
Pankaj
Photo of md5-6eb5a1ce5c2a902eaa7ed5dae82ed54b
Pankaj
06:11 AM
> Typesense does prefix search only for the last word in the query. Since inv is the first word in the query inv company it won't match inv123456
Kishore Nallan is there a way/option to change this behaviour and make it match both fields ?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
06:12 AM
No that's not possible.

1

Jainil
Photo of md5-bea1e4531665b4608c47d00462429d3a
Jainil
02:10 PM
Can this possibly be solved by using filter_by=invoice_number:inv instead of putting inv in the search query?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
02:11 PM
No filtering does not support any prefix searching.

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:00 PM
Pankaj Could you add your example as a comment to this issue: https://github.com/typesense/typesense/issues/920