Customized sort in ElasticSearch

Can I use custom sort in ES?
Like, in my ES data, one field values are -> "A", "A", "B", "B", "C", "C", "C", "D"
Can I sort this like -> "D", "B", "B", "C", "C", "C", "A", "A"

If we can sort like this, how the query structure will be looked like?

If anyone aware about it, can you please help me here?

Have you looked at using scripted sort to potentially achieve this? I am not sure it is possible but it is the only way I can see to get that type of result.

Hi, @Christian_Dahlqvist, thanks for the reply. Actually I was not aware of that thing. Let me see.

Hi @Christian_Dahlqvist I was playing around the scripted sort and painless API but unable to achieve the said scenario.
Is there any other way we can do that?

Not that I can think of.

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