# Nested documents returned in search results by error

**URL:** https://discuss.elastic.co/t/nested-documents-returned-in-search-results-by-error/19004
**Category:** Elasticsearch
**Created:** [July 31, 2014, 10:12am UTC](https://discuss.elastic.co/t/nested-documents-returned-in-search-results-by-error/19004 "2014-07-31T10:12:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jennifer\_Cumming](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Jennifer\_Cumming](https://discuss.elastic.co/u/Jennifer_Cumming)
#### Post date: [July 31, 2014, 10:12am UTC](https://discuss.elastic.co/t/nested-documents-returned-in-search-results-by-error/19004/1 "2014-07-31T10:12:23Z")

</div>

I'm trying to use a nested object type to store some additional data but  
running into some inconsistencies versus the documentation when it comes to  
searching. From the documentation it sounds like a simple search like

{  
"query": {  
"bool": {  
"must" : {  
"query\_string": {  
"query": "jane"  
}  
}  
}  
}  
}

Should not return any documents where the only instance of "jane" is in a  
nested document. Yet when I run this search against my test data it does.  
Mystery deepens when I then use the explain API to try work out why it was  
returned and it says the document was matched on \_all yet I have  
include\_in\_all set to false in the mapping.

mapping and data for the two documents  
here [https://gist.github.com/anonymous/febab9c09bdf9ea9849c](https://gist.github.com/anonymous/febab9c09bdf9ea9849c)  
Search results here [https://gist.github.com/anonymous/74311fab5e2452938505](https://gist.github.com/anonymous/74311fab5e2452938505)  
Explain here [https://gist.github.com/anonymous/4fed3653658d70fb0df8](https://gist.github.com/anonymous/4fed3653658d70fb0df8)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4a2ab8e2-f725-4eb5-a4ee-1cb9d6a5097f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4a2ab8e2-f725-4eb5-a4ee-1cb9d6a5097f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Jennifer\_Cumming](https://avatars.discourse-cdn.com/v4/letter/j/cab0a1/32.png) [@Jennifer\_Cumming](https://discuss.elastic.co/u/Jennifer_Cumming)
#### Post date: [August 4, 2014, 3:12pm UTC](https://discuss.elastic.co/t/nested-documents-returned-in-search-results-by-error/19004/2 "2014-08-04T15:12:23Z")

</div>

> Update to this. I installed the lastest version and this fixed my issue  
> for a while until I ran a search with a query with highlighting that should  
> not have hit on the nested documents but they appeared in the results.. At  
> this point I started to see the nested documents hitting on every query  
> (with or without highlighting) due to their contents now being included in  
> \_all. It looks like doing the highlighting pulled everything into the \_all  
> field.

On Thursday, 31 July 2014 11:12:23 UTC+1, Jennifer Cumming wrote:

> I'm trying to use a nested object type to store some additional data but  
> running into some inconsistencies versus the documentation when it comes to  
> searching. From the documentation it sounds like a simple search like
> 
> {  
> "query": {  
> "bool": {  
> "must" : {  
> "query\_string": {  
> "query": "jane"  
> }  
> }  
> }  
> }  
> }
> 
> Should not return any documents where the only instance of "jane" is in a  
> nested document. Yet when I run this search against my test data it does.  
> Mystery deepens when I then use the explain API to try work out why it was  
> returned and it says the document was matched on \_all yet I have  
> include\_in\_all set to false in the mapping.
> 
> mapping and data for the two documents here  
> [Mapping and data for nested type · GitHub](https://gist.github.com/anonymous/febab9c09bdf9ea9849c)  
> Search results here [Search results · GitHub](https://gist.github.com/anonymous/74311fab5e2452938505)  
> Explain here [Return from explain api on the document with id bronte · GitHub](https://gist.github.com/anonymous/4fed3653658d70fb0df8)

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9e3c1f7a-af70-43ee-9415-585b898de54a%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9e3c1f7a-af70-43ee-9415-585b898de54a%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:11am UTC](https://discuss.elastic.co/t/nested-documents-returned-in-search-results-by-error/19004/3 "2017-07-06T01:11:00Z")

</div>


