We have a field in index - TempNo which has to be text type but all values in this field are number (integer)
When i am doing sorting (desc) on this field , sort does not happen correctly. I am not getting result in desc order of TempNo.
It seems it is because of text type . How can I sort it correctly ? (type is text but sorting should happen based on Number)
If you want number based sorting, take a look at multi fields and index this field as a string as well as an integer. This way you can specify the string based for all your search operations and the integer based field for sorting.
I tried the same option but 70001588 appear before 100416687.
I have changed the mapping like below
and using query as below
Am I doing any thing wrong?
please format your snippets properly. This is super hard to read.
In order to fully understand the issue, you need to provide a minimal, but complete reproducible example, that includes index creation, mapping, sample documents and your query, otherwise everyone is working on assumptions, how your may have configured Elasticsearch and come to wrong conclusions.
That said, a keyword field is still a string field and not an integer field, so you are still not properly sorting by a number.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.