Queryable Int32 Field for Sorting and Query By
TLDR JP wants to make an int32
field queryable and sortable. Jason suggests creating integer and string versions of the field, but acknowledges the need for integer fields in query_by.
Mar 02, 2023 (7 months ago)
JP
08:58 PMint32
field that we want to be queryable (using query_by
), but also to sort_by
. For it to be queryable, we have to set the field's type to string
in the schema, but sorting on it produces the wrong results. Since these values are now strings instead of numbers if we sort them ascending, we get results for 1
, 10
, 100
, 2
, 20
, etc instead of 1
, 2
, 3
, etc.Is there a way to do a type cast or transformation on the field when sorting? Something like
sort_by: parseInt32(theField):asc
Jason
09:00 PMThis came up recently in another context, mind copy-pasting your use-case into this GitHub issue: https://github.com/typesense/typesense/issues/917
This gives an even better use-case to support integer fields in query_by
JP
09:02 PMTypesense
Indexed 2776 threads (79% resolved)
Similar Threads
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.
Querying Integer Fields in query_by
Saurabh wants to query an integer field in `query_by`. Kishore Nallan suggests indexing the field as a string instead to properly query it.
Methods for Fetching, Querying, and Modifying Collections in Typesense
Bill inquired about performing OR queries, querying empty arrays and modifying collections in Typesense. Kishore Nallan explained the current limitations and provided workarounds and recommendations for each case. The conversation also touched upon the usage of cache in Typesense and the workings of the _eval function.