Issues Sorting Multiple Fields with Sort_by in Typesense Query
TLDR 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.


Apr 18, 2021 (29 months ago)
Rishabh
10:18 PMJason
10:20 PMRishabh
10:22 PM&page=1&q=&sort_by=jobDeadline:asc,projectCreationTime:desc&filter_by=
Rishabh
10:22 PMJason
10:24 PMRishabh
10:25 PMRishabh
10:25 PMRishabh
10:29 PMRishabh
10:29 PMJason
10:31 PMRishabh
10:31 PMRishabh
10:32 PMRishabh
10:32 PMJason
10:32 PMjobDeadline:asc
. I don't see any overlapping jobDeadline values for the projectCreationTime:desc
to kick-in thoughRishabh
10:34 PMJason
10:34 PMRishabh
10:36 PMRishabh
10:37 PMJason
10:37 PMRishabh
10:37 PMRishabh
10:38 PMRishabh
10:39 PM
Jason
10:42 PMNo, but I'm trying to visualize how this would work. For every record, there needs to be a single value to know which ordered position to put it in, right?
Jason
10:43 PMRishabh
10:44 PMJason
10:46 PMI don't think so either. But if you're referring to the comparison chart, what Meilisearch & Algolia do not support that Typesense supports, is support for dynamic sorting, as part of the search parameters. With Meilisearch & Algolia, you have to define the sort order upfront. With Typesense, you can sort on any integer fields on the fly at search time.
Rishabh
10:47 PMRishabh
10:51 PM{
"document": {
"id": "5bdb10bca52ece560e8a8a17",
"projectCreationTime": 10,
"jobDeadline": 50
}
},
{
"document": {
"id": "5bdb1278a52ece560e8a8a26",
"projectCreationTime": 15,
"jobDeadline": 40
}
},
{
"document": {
"id": "5bdb1235a52ece560e8a8a1c",
"projectCreationTime": 20,
"jobDeadline": 22
}
}]
Rishabh
10:51 PMJason
10:53 PM[{
"document": {
"id": "5bdb10bca52ece560e8a8a17",
"jobDeadline": 10,
"projectCreationTime": 1
},
},
{
"document": {
"id": "5bdb1278a52ece560e8a8a26",
"jobDeadline": 6,
"projectCreationTime": 5
},
},
{
"document": {
"id": "5bdb1235a52ece560e8a8a1c",
"jobDeadline": 9,
"projectCreationTime": 3
},
}]
How would you sort by
jobDeadline:asc,projectCreationTime:desc
in the way you've described.Jason
10:53 PMRishabh
10:54 PMJason
10:55 PMI think so too, not just in Typesense - but in general, with sorting as a concept.
But I'm trying to see if I'm missing something obvious or the possibility of a new feature 🙂
Rishabh
10:55 PM
Typesense
Indexed 2764 threads (79% resolved)
Similar Threads
Merging Results of Multi-Search Queries: Workarounds and Future Features
Julian wanted to merge results from two similar collections. Kishore Nallan confirmed it's a feature that might be implemented but hasn't been prioritised. Both Julian and robert plan to use client-side solutions for now.
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.


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.



Resolving Typesense Result Issue in Document Collection Queries
Mike was encountering errors when searching for specific query in their Typesense document collection. Jason suggested it may be due to the `drop_tokens_threshold` setting. There was a misunderstanding but after further explanation from Jason, Mike understood and decided to continue the conversation via email.

Discussing Ability to Sort by a Text Field
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.