Hi! :wave: We have a `int32` field that we want to...
# community-help
j
Hi! 👋 We have a
int32
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
j
Hey JP! Unfortunately no. So you would have to create an integer version of the field and use that for sorting and creating a string version of the field to use for query_by. This 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
j
Thanks for the quick response! Definitely, I'll add it to the issue.