# Sorting by language field in multilanguage scenario

**URL:** <https://discuss.elastic.co/t/sorting-by-language-field-in-multilanguage-scenario/121654>\
**Category:** Elasticsearch\
**Created:** [February 27, 2018, 12:24pm UTC](https://discuss.elastic.co/t/sorting-by-language-field-in-multilanguage-scenario/121654 "2018-02-27T12:24:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnatten](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jnatten/32/71781_2.png) [@jnatten](https://discuss.elastic.co/u/jnatten)\
**Post date:** [February 27, 2018, 12:24pm UTC](https://discuss.elastic.co/t/sorting-by-language-field-in-multilanguage-scenario/121654/1 "2018-02-27T12:24:59Z")

</div>

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.](https://pastebin.com/Q56LHrui)

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](https://pastebin.com/wRB561uB) 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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 27, 2018, 12:25pm UTC](https://discuss.elastic.co/t/sorting-by-language-field-in-multilanguage-scenario/121654/2 "2018-03-27T12:25:02Z")

</div>

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