Discussing Ability to Sort by a Text Field
TLDR Aljosa asks about sorting by text fields and proposes a workaround. Kishore Nallan discusses database implications and possible workarounds, informing that changes may require reindexing. Andrew expresses interest in string sorting.
Oct 23, 2021 (25 months ago)
Aljosa
03:48 PMOr perhaps I'm crazy and you can do alphabetical sorts ?
Aljosa
03:48 PMAljosa
03:49 PMKishore Nallan
03:49 PMKishore Nallan
03:50 PMAljosa
03:51 PMAljosa
03:51 PMKishore Nallan
03:54 PMKishore Nallan
03:55 PMsort_by=field1:asc,field2:asc
Kishore Nallan
03:56 PMKishore Nallan
03:57 PMAljosa
03:58 PMI feel like I'm missing something in my understanding. In our case we have a regular "name" field which is maybe 30 characters at most. We could call it a "title" field to better illustrate the type of field.
So before actually sending the documents to typesense for indexing, is there anything preventing me from pre-sorting in my code and creating a numerical value from 1 to X based on the output of that sort ?
Aljosa
03:59 PMKishore Nallan
04:00 PMKishore Nallan
04:01 PMKishore Nallan
04:03 PMAljosa
04:08 PMIn our case we push items to the database and have a listener/subscriber on
@AfterInsert
and @AfterUpdate
events which keeps Typesense in sync. We'd need to add a trigger which updates the sort on all items if the title field is modified on one of them.It works better for our case because despite having millions of documents, they are segregated cleanly into about 5-10k chunks.
As for supporting sorting on any string length, it doesn't seem worth it. Algolia certainly discourage people from doing it except in rare circumstances and even then as a separate index or something.
Sorting by a fixed length title sort of field could be interesting but I'm not sure how to determine what an optimal length is. 8 characters is probably good enough because at a glance I doubt most people can mentally sort past a certain number of characters, although in titles starting with the same word it would be easier to identify something that's not sorted correctly past the first 8 characters.
Kishore Nallan
04:13 PMKishore Nallan
04:13 PMAljosa
04:15 PMAljosa
04:16 PMKishore Nallan
04:16 PMAndrew
05:43 PMTypesense
Indexed 2779 threads (79% resolved)
Similar Threads
Issues Sorting Multiple Fields with Sort_by in Typesense Query
Rishabh was having trouble sorting two fields separately with a single query. Jason explained that a secondary sorting will only occur if the first sort results in matching values. They clarified the functionality of sorting in various search engines.
Issue with Sorting Search Request
Anton encounters an issue with sorting a search request due to an assuredly existing field appearing absent. Jason complements by revealing string sorting isn't supported. Kishore Nallan confirms future support for string sorting, despite its memory-demands.
Querying with Typesense-Js and Handling Null Values
michtio was querying using typesense-js and receiving fewer results than expected. Kishore Nallan suggested using different query parameters. Further discussion led to the handling of 'null' values and filtering syntax in the search queries. The thread ended with Jason offering migration support from Algolia to Typesense.
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.
Adjusting Text Match Score Calculation in TypeSense
Johannes wanted to modify the Text Match Score calculation in TypeSense to improve search results returns. With counsel from Jason and Kishore Nallan, various solutions were proposed, including creating a Github issue, attempting different parameters, and updating Docker to a new version to resolve the matter.