#community-help

Sorting Issue in Typesense Schema

TLDR Keith had issues sorting by the field 'year' after changing its type to a string. Jason clarified that Typesense currently only supports numeric sorting and offered a workaround.

Powered by Struct AI

1

Dec 17, 2021 (25 months ago)
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
05:01 PM
Jason I had a facet field that was an init, everything was fine, but I changed it to be a string but now I’m getting an error of Error: 404 - Could not find a field named year in the schema for sorting. The field itself is optional, which it was before, does there always have to have a value though to be set in
additionalSearchParameters: {
    queryBy: "title,barcode",
    sortBy: "_text_match:desc,year:desc",
}
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:14 PM
Keith Typesense currently only supports sorting by numeric fields, the error message needs to be improved there
05:14
Jason
05:14 PM
We plan to tackle sorting by strings in the next few weeks (mid to late Jan)

1

Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
05:15 PM
Um so why does _textmatch:desc work?
05:15
Keith
05:15 PM
Or is that the relevancy score?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:16 PM
That’s a numeric relevancy score
05:16
Jason
05:16 PM
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
05:19 PM
Awesome, I’ll give that a try!
05:26
Keith
05:26 PM
Actually, that doesn’t make a whole lot of sense to be tbh
05:28
Keith
05:28 PM
Ohhh they just added two fields?
05:32
Keith
05:32 PM
My problem that I’m trying to solve that for my year field specifically, I have some instances where it could be “2021/22”
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
05:34 PM
Yup
Keith
Photo of md5-49c23d5dc46241ca1af5233658633765
Keith
05:59 PM
That’s what I just did for now if anyone is asking

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3015 threads (79% resolved)

Join Our Community

Similar Threads

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.

11

70
4mo

Query on Facet Values, `max_facet_values` , and `facet_query_num_typos`.

Jan asked about sorting facet values, managing `max_facet_values` and issues with `facet_query_num_typos`. Jason clarified the details on instantsearch widget handling of `max_facet_values` and identified a bug on the Typesense Server. Jason suggested a solution to the sorting issue.

2

23
1mo

Sorting Results in Typesense and Handling Errors

Ramees asks about sorting results by distance in Typesense, entering a list of strings as a field, and resolving an error with `fields` format. Kishore Nallan assists with these issues and advises on storing timestamps and proper authentication.

2

46
30mo

Solving Searchable String ID Sorting Issue

Mubashirullah needed to sort by string id, which was not supported. Kishore Nallan offered a preview Docker build with the feature. Mubashirullah expressed satisfaction with the solution.

3

12
25mo

Troubleshooting Typesense API Sorting Error in Item Collections

Nikhil encountered a sorting error when using Typesense API due to an optional reference field in the items collection schema. Harpreet and Jason helped debug and identified a bug with sorting in general for 2 fields with the first one being the join field, promising a fix in a forthcoming build.

2

45
2w