How can I sort results based by a custom field in a multi-field property?

I am working on upgrading a system at work from using ES1 to ES7.

Part of the ES1 implementation included a custom plugin to add an analyzer for custom sorting. The custom sorting behavior we have is similar to "natural sort", but extended to deal with legal codes. For example, it will sort "1.1.1" before "1.10.1". We've been calling this "legal sort". We used this plugin to add an extra ".legalsort" field to multi-field properties in our index, and then we would sort based on this field when searching.

I am currently trying to adapt the main logic for indexing and searching to ES7. I am not trying to replace the "legal sort" plugin yet. When trying to implement sorting for searches, I ran into the error "Fielddata is disabled on text fields by default". The solution I've seen suggested for that is to add a ".keyword" field for any text properties, which will be used for sorting and aggregation. This "works", but I don't see how I can then apply our old logic of sorting based on a ".legalsort" field.

Is there a way to sort on a field other than ".keyword", which can use a custom analyzer, like we were able to in ES1?

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