# Nested match\_all filter filters documents without nested documents

**URL:** https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925
**Category:** Elasticsearch
**Created:** [July 24, 2013, 8:03pm UTC](https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925 "2013-07-24T20:03:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![btiernay](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@btiernay](https://discuss.elastic.co/u/btiernay)
#### Post date: [July 24, 2013, 8:03pm UTC](https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925/1 "2013-07-24T20:03:37Z")

</div>

Hi all,

I have a curl example that illustrates my issue:

> <https://gist.github.com/btiernay/6073932>

Basically, I would expect that the following 2 queries would always behave  
the same:

_(a)_  
{  
"size":0,  
"query":{  
"nested":{  
"query":{  
"match\_all":{}  
},  
"path":"list"  
}  
},  
"fields":[]  
}

_(b)_  
{  
"size":0,  
"query":{  
"match\_all":{}  
},  
"fields":[]  
}

However, (a) seems to filter documents without nested docs. Is this the  
expected behaviour?

Thank you in advance,

Bob

--  
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: ![btiernay](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@btiernay](https://discuss.elastic.co/u/btiernay)
#### Post date: [July 25, 2013, 12:53pm UTC](https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925/2 "2013-07-25T12:53:37Z")

</div>

After doing some more digging it appears as though this is part of the semantics of how elasticsearch implements nested queries in NestedQueryParser which uses lucene's ToParentBlockJoin:

lucene.apache.org/core/4\_3\_0/join/org/apache/lucene/search/join/package-summary.html

lucene.apache.org/core/4\_3\_0/join/org/apache/lucene/search/join/ToParentBlockJoinQuery.html

I would greatly appreciate a confirmation, but I think an elaboration in the ES docs to mention that it performs "inner join"-like semantics would be very useful to prevent confusion.

Cheers,

Bob

--  
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: [July 29, 2013, 9:48am UTC](https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925/3 "2013-07-29T09:48:17Z")

</div>

This is expected behaviour, when using the nested query all documents  
without nested inner objects are automatically excluded.  
It makes sense to explicitly document this behaviour.

On 25 July 2013 14:53, btiernay [rtiernay@gmail.com](mailto:rtiernay@gmail.com) wrote:

> After doing some more digging it appears as though this is part of the  
> semantics of how elasticsearch implements nested queries in  
> NestedQueryParser which uses lucene's ToParentBlockJoin:
> 
> [org.apache.lucene.search.join (Lucene 4.3.0 API)](http://lucene.apache.org/core/4_3_0/join/org/apache/lucene/search/join/package-summary.html)
> 
> [ToParentBlockJoinQuery (Lucene 4.3.0 API)](http://lucene.apache.org/core/4_3_0/join/org/apache/lucene/search/join/ToParentBlockJoinQuery.html)
> 
> I would greatly appreciate a confirmation, but I think an elaboration in  
> the ES docs to mention that it performs "inner join"-like semantics would  
> be very useful to prevent confusion.
> 
> Cheers,
> 
> Bob
> 
> --  
> 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: ![btiernay](https://avatars.discourse-cdn.com/v4/letter/b/bb73d2/32.png) [@btiernay](https://discuss.elastic.co/u/btiernay)
#### Post date: [August 7, 2013, 12:59pm UTC](https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925/4 "2013-08-07T12:59:45Z")

</div>

Thanks for the confirmation 🙂

--  
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:22am UTC](https://discuss.elastic.co/t/nested-match-all-filter-filters-documents-without-nested-documents/12925/5 "2017-07-06T02:22:26Z")

</div>


