Sorting by language field in multilanguage scenario

Hi there,

I'm in a situation where i need to store searchable multi-language documents.
As of now the mapping looks something like: this.

Now that is fine as long as you search for a single language, however when you are looking for any language a problem occurs:

How do i know which language i matched on? And how to i sort that language by title?

I tried doing this with highlight, which at least lets me know which language matched, but sorting by title of the language found in highlight i couldn't figure out.
So i thought maybe splitting the documents up into one document per language (So one article and id would be multiple documents).
Then i could use aggregations like this to only get the best matched result per id?
That works, but still i don't know how to sort by title.

So i guess my questions are: Is it possible to sort aggregations on "title.*"?
Or: Can get some sort of inner_hits or highlighting to a painless sortscript?
Or probably most likely: Am i doing this entirely wrong?

Any help is greatly appreciated.

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