How to sort number stored as string (keyword)

Some numerical attribute in my data is mapped as keyword and stored as string. I want to sort it as 1, 2, 10, 15 or when descending. 15, 10, 2, 1. I have tried multiple solutions available online but nothing works. Data will contain only number as string. There won't be any mix like ABC10.
I can not change mapping and performance is not a big issue

Welcome!

You need to change the mapping (reindex that is). Or use https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-sort-context.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.