Getting an array inside a document sorted

(azitabh) #1

Let's say this is the document indexed in elasticsearch:
{:id=>123,:a=>10, :b=>12, :c=>[{:x=>A,:y=>102,:z=>92},{:x=>B,:y=>110,:z=>96},{:x=>C,:y=>94,:z=>106}]}

And I am firing some query to elasticsearch and it's guaranteed that this will be the only document in the result set.
Is there a way to instruct elasticsearch that the array 'c' in the returned document should be sorted on the basis of (y+3z).

Since the expression will be different every time, so I can't take care of this while indexing.


(system) #2