Understanding Typesense Data Sorting Behavior
TLDR Imtiaz had a query about data sorting order in Typesense. Kishore Nallan clarified that data with the same text match score are sorted based on their internal sequential ID, descending.
Jan 20, 2022 (24 months ago)
Imtiaz
10:46 AMA subset of my data appears as follows (NB - when seeding these are added to the index in the order listed below):
icd10,description
E78.1,Pure hyperglyceridaemia
E78.2,Mixed hyperlipidaemia
E78.3,Hyperchylomicronaemia
and my index is as follows:
{
'name': 'diagnosis',
'fields': [
{'name': 'id', 'type': 'string'}, # maps to icd10
{'name': 'code', 'type': 'string'}, # maps to icd10
{'name': 'description', 'type': 'string'}, # maps to description
]
}
Running a query
E78
I get the results in reverse order (E78.3, followed by E78.2 and E78.1)If I seed the data in reverse order than I get the results in the correct order.
I would just like to understand this behaviour better, and how order of insertion affects sorting (and if its fine to rely on this for my use case since the data wont change).
Kishore Nallan
10:48 AME78
all matching documents have the same text match score, so to break the tie, we sort on their internal document ID, which is an increasing sequential ID.Imtiaz
10:50 AMKishore Nallan
10:50 AMImtiaz
10:50 AMKishore Nallan
10:50 AMTypesense
Indexed 3005 threads (79% resolved)
Similar Threads
Solving Conflicts in Searching and Ordering Data with Typesense
SamHendley faced an issue with search result order in Typesense. Kishore Nallan explained two behaviors that affected the ranking and pledged to change these, while also considering an additional suggestion from SamHendley. These changes were implemented in version `0.24.0.rcn39`.
Resolve Facets and Sorting Issues with Typesense
Ethan needed assistance with getting all facet values and sorting results by date using Typesense. Jason provided guidance on how to use Typesense properties to accomplish these tasks, and resolved issues related to specific use-cases provided by Ethan and Rushil.
Issues With `text_match` Scoring for Search Queries in Typesense
Colin encountered issues with the `text_match` scoring on Typesense v0.23.1. Jason and Kishore Nallan identified a potential issue with numeric overflow in the text match score and applied an unverified patch. The final resolution is unclear.