# New nested\_filter for sorting an object based on an array of nested objects

**URL:** <https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349>\
**Category:** Elasticsearch\
**Created:** [March 28, 2013, 10:59am UTC](https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349 "2013-03-28T10:59:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_3](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@David\_3](https://discuss.elastic.co/u/David_3)\
**Post date:** [March 28, 2013, 10:59am UTC](https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349/1 "2013-03-28T10:59:26Z")

</div>

I'm trying out a new feature for sorting an object based on its nested  
objects using the new 'nested\_filter' field.  
I'm on elasticsearch version 20.6  
I cannot get it to work so far, it doesn't sort at all when using the  
nested object as the field and including a filter for another nested object  
field.

Does this work in version 20.6?

This is the query and sort:  
{  
"query": {  
"match\_all": {}  
},  
"sort": [  
{  
"nested.field": {  
"mode": "avg",  
"order": "asc",  
"nested\_filter": {  
"term": {  
"nested.otherfield.id": 14  
}  
}  
}  
}  
]  
}  
It doesn't seem to be sorting at all and I tried including the  
"nested\_path": "nested" field but it doesn't like it.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [March 28, 2013, 11:06am UTC](https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349/2 "2013-03-28T11:06:25Z")

</div>

Sorting on fields inside nested objects is a 0.90 only feature. It doesn't  
work in ES version 0.20.6

On 28 March 2013 11:59, David [davidrockett@gmail.com](mailto:davidrockett@gmail.com) wrote:

> I'm trying out a new feature for sorting an object based on its nested  
> objects using the new 'nested\_filter' field.  
> I'm on elasticsearch version 20.6  
> I cannot get it to work so far, it doesn't sort at all when using the  
> nested object as the field and including a filter for another nested object  
> field.
> 
> Does this work in version 20.6?
> 
> This is the query and sort:  
> {  
> "query": {  
> "match\_all": {}  
> },  
> "sort": [  
> {  
> "nested.field": {  
> "mode": "avg",  
> "order": "asc",  
> "nested\_filter": {  
> "term": {  
> "nested.otherfield.id": 14  
> }  
> }  
> }  
> }  
> ]  
> }  
> It doesn't seem to be sorting at all and I tried including the  
> "nested\_path": "nested" field but it doesn't like it.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![David\_3](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@David\_3](https://discuss.elastic.co/u/David_3)\
**Post date:** [March 28, 2013, 12:29pm UTC](https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349/3 "2013-03-28T12:29:01Z")

</div>

Do you plan to include it in a stable release?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [March 28, 2013, 12:46pm UTC](https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349/4 "2013-03-28T12:46:22Z")

</div>

Yes, in the 0.90 GA release (expected in the coming weeks). It is not  
planned to be included in a 0.20.x release.

On 28 March 2013 13:29, David [davidrockett@gmail.com](mailto:davidrockett@gmail.com) wrote:

> Do you plan to include it in a stable release?

--  
Met vriendelijke groet,

Martijn van Groningen

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:43am UTC](https://discuss.elastic.co/t/new-nested-filter-for-sorting-an-object-based-on-an-array-of-nested-objects/11349/5 "2017-07-06T02:43:53Z")

</div>


