# Unexpected results when sorting with deeply nested filters

**URL:** <https://discuss.elastic.co/t/unexpected-results-when-sorting-with-deeply-nested-filters/65367>\
**Category:** Elasticsearch\
**Created:** [November 8, 2016, 2:58pm UTC](https://discuss.elastic.co/t/unexpected-results-when-sorting-with-deeply-nested-filters/65367 "2016-11-08T14:58:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmeskers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pmeskers/32/13026_2.png) [@pmeskers](https://discuss.elastic.co/u/pmeskers)\
**Post date:** [November 8, 2016, 2:58pm UTC](https://discuss.elastic.co/t/unexpected-results-when-sorting-with-deeply-nested-filters/65367/1 "2016-11-08T14:58:03Z")

</div>

Howdy all.

I'm trying to perform some sorting based on the attributes of a document's deeply nested children. The example is provided here, along with `curl` commands for reproducing the index/mappings:

> <https://gist.github.com/pmeskers/eee33df28af6556b27836fd38255f366>

Basically, when my nested\_filter has terms that are applied to different nested paths (in the above example, it's `books.published` and `books.genre_scores.genre_id`), some weird results are being used as the sorting value.

Can anyone provide some insight as to _why_ this behavior is happening? And additionally, if there are any viable solutions to the proposed query/sort?

Thanks!  
Paul

---

<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:** [December 6, 2016, 2:58pm UTC](https://discuss.elastic.co/t/unexpected-results-when-sorting-with-deeply-nested-filters/65367/2 "2016-12-06T14:58:02Z")

</div>

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