Here is a sample document:
"description": "Example (English)"
"description": "Example (Italiano)"
"description": "Example (Francais)"
We have a locale filter, so ES returns the documents which have description
in locale acceptable by user and ordered by his preference e.g. en-gb,en,it
(similar to HTTP Accept-Language header without quality parameter). This
works fine and also searching by description dependent on locale.
On frontend we always use just one description per document, the one with
locale which is the most accurate to user's preference. This is done on
Java side. But what we need is to allow ordering by the descriptions field,
which is array in ES. I know that it isn't possible to order by array
fields as it doesn't make sense. Is there any possibility to filter out
unnecessary descriptions and order by description when we know which
description will be used based on user's language preference?
The last possible solution we would like to avoid is to read all matched
documents and order it on Java side, but we use pagination, and after that
we would read all documents, order them, and return only those which are on
the requested page.