Elasticsearch sorting by matching array item
<p>I have a following structure in indexed documents:</p>

<pre><code>document1: "customLists":[{"id":8,"position":8},{"id":26,"position":2}]
document2: "customLists":[{"id":26,"position":1}]
document3: "customLists":[{"id":8,"position":1},{"id":26,"position":3}]
</code></pre>

<p>I am able to search matching documents that belong to a given list with match query "customLists.id = 26". But I need to sort the documents based on the position value within that list and ignore positions of the other lists. </p>

<p>So the expected results would be in order of document2, document1, document3</p>

<p>Is the data structure suitable for this kind of sorting and how to handle this?</p>