Can fields in the mapping be made non sortable

Can we make a field in the mapping as non sortable?
The way we can make a field unsearchable by setting the mapping parameter "index:false" ,is there a way to make fields non sortable?
Is there any mapping parameter that can be used or any other way ?

The data structure for sorting and aggregations is doc_values and you can disable that: doc_values | Elasticsearch Reference [7.11] | Elastic Though that will also affect aggregations and not just sorting.

Why do you want to do that? To save disk space or is there another reason for that? Maybe there is a better solution to get that done.

@xeraa
Few fields like a unique code may not be be used for sorting at all but is of type keyword (can be of other types as well), in that case I don't want it to be sortable.
Ultimately Iam looking for a list of all the fields that are sortable ,so I don't want to include those which will never be sorted in my case,so Iam trying to make fields non sortable.

Aggregations and sorting use the same internal data-structure, so you can only disable them together with doc_values. I'm not really aware of any other was just to turn off sorting on a field alone. Also note that aggregations could be abused to do something similar like sorting (using min / max aggregations), so you won't be able to hide this information.

Depending on what you want to do with that field, you could even turn off the enabled setting if you need none of those features.

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