# How to avoid "failed to find nested object under path" when searching over many indexes?

**URL:** https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804
**Category:** Elasticsearch
**Created:** [May 22, 2012, 9:19am UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804 "2012-05-22T09:19:01Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [May 22, 2012, 9:19am UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/1 "2012-05-22T09:19:01Z")

</div>

Hi,

is it possible to search on indexes that have no nested objects in the  
mapping when searching with a nested query over many indexes?

I get the following error message "failed to find nested object under  
path". The situation is, some indexes have a nested object  
"dc:subject.xbib:subject", some not. I would expect a successful search. It  
would be nice to fail silently on those indexes where the mapping is  
different, even if another mapping such as an un-nested field is present.

To work around, I must either constrain the search to the indexes that have  
the nested object in the mapping, or I need to extend the nested object  
mapping to all indexes, even if they do not make use of it.

Best,

Jörg

[2012-05-22 10:54:18,241][DEBUG][action.search.type] [Blitzkrieger]  
[oai][4], node[3ByGVhulSmeXXxO3jtEUxA], [P], s[STARTED]: Failed to execute  
[org.elasticsearch.action.search.SearchRequest@1aed904a]  
org.elasticsearch.search.SearchParseException: [oai][4]: from[0],size[10]:  
Parse Failure [Failed to parse source [{"from":0,"size":10, "query" :  
{"nested":{"path":"dc:subject.xbib:subject","score\_mode":"avg","query":{"bool":{"must":[{"term":{"dc:subject.xbib:subject.xbib:subjectAuthority":"RSWK"}},{"text":{"dc:subject.xbib:subject.xbib:subjectValue":"köln"}}]}}}}}]]  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:557)  
at  
org.elasticsearch.search.SearchService.createContext(SearchService.java:470)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:228)  
at  
org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)  
at  
org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)  
at  
org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
at java.lang.Thread.run(Thread.java:722)  
Caused by: org.elasticsearch.index.query.QueryParsingException: [oai]  
[nested] failed to find nested object under path [dc:subject.xbib:subject]  
at  
org.elasticsearch.index.query.NestedQueryParser.parse(NestedQueryParser.java:117)  
at  
org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:192)  
at  
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:243)  
at  
org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223)  
at  
org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:545)

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [May 22, 2012, 9:39am UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/2 "2012-05-22T09:39:24Z")

</div>

> To work around, I must either constrain the search to the indexes that  
> have the nested object in the mapping, or I need to extend the nested  
> object mapping to all indexes, even if they do not make use of it.

Or you can use the indices query to send two different versions:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

clint

---

<div class="post-metadata">

### Author: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [May 22, 2012, 9:25pm UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/3 "2012-05-22T21:25:59Z")

</div>

Since I use a front-end query translator for translating from another query  
language to Elasticsearch DSL, I have only one version.

Jörg

On Tuesday, May 22, 2012 11:39:24 AM UTC+2, Clinton Gormley wrote:

> > To work around, I must either constrain the search to the indexes that  
> > have the nested object in the mapping, or I need to extend the nested  
> > object mapping to all indexes, even if they do not make use of it.
> 
> Or you can use the indices query to send two different versions:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/indices-query.html)
> 
> clint

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [May 25, 2012, 8:30pm UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/4 "2012-05-25T20:30:46Z")

</div>

You will still get a response back, just the shards belonging to the index  
with no nested mapping will be marked as failed.

On Tue, May 22, 2012 at 11:19 AM, Jörg Prante [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Hi,
> 
> is it possible to search on indexes that have no nested objects in the  
> mapping when searching with a nested query over many indexes?
> 
> I get the following error message "failed to find nested object under  
> path". The situation is, some indexes have a nested object  
> "dc:subject.xbib:subject", some not. I would expect a successful search. It  
> would be nice to fail silently on those indexes where the mapping is  
> different, even if another mapping such as an un-nested field is present.
> 
> To work around, I must either constrain the search to the indexes that  
> have the nested object in the mapping, or I need to extend the nested  
> object mapping to all indexes, even if they do not make use of it.
> 
> Best,
> 
> Jörg
> 
> [2012-05-22 10:54:18,241][DEBUG][action.search.type] [Blitzkrieger]  
> [oai][4], node[3ByGVhulSmeXXxO3jtEUxA], [P], s[STARTED]: Failed to execute  
> [org.elasticsearch.action.search.SearchRequest@1aed904a]  
> org.elasticsearch.search.SearchParseException: [oai][4]: from[0],size[10]:  
> Parse Failure [Failed to parse source [{"from":0,"size":10, "query" :  
> {"nested":{"path":"dc:subject.xbib:subject","score\_mode":"avg","query":{"bool":{"must":[{"term":{"dc:subject.xbib:subject.xbib:subjectAuthority":"RSWK"}},{"text":{"dc:subject.xbib:subject.xbib:subjectValue":"köln"}}]}}}}}]]  
> at  
> org.elasticsearch.search.SearchService.parseSource(SearchService.java:557)  
> at  
> org.elasticsearch.search.SearchService.createContext(SearchService.java:470)  
> at  
> org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:228)  
> at  
> org.elasticsearch.search.action.SearchServiceTransportAction.sendExecuteQuery(SearchServiceTransportAction.java:140)  
> at  
> org.elasticsearch.action.search.type.TransportSearchQueryThenFetchAction$AsyncAction.sendExecuteFirstPhase(TransportSearchQueryThenFetchAction.java:80)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:204)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.performFirstPhase(TransportSearchTypeAction.java:191)  
> at  
> org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction$2.run(TransportSearchTypeAction.java:177)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)  
> at java.lang.Thread.run(Thread.java:722)  
> Caused by: org.elasticsearch.index.query.QueryParsingException: [oai]  
> [nested] failed to find nested object under path [dc:subject.xbib:subject]  
> at  
> org.elasticsearch.index.query.NestedQueryParser.parse(NestedQueryParser.java:117)  
> at  
> org.elasticsearch.index.query.QueryParseContext.parseInnerQuery(QueryParseContext.java:192)  
> at  
> org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:243)  
> at  
> org.elasticsearch.index.query.IndexQueryParserService.parse(IndexQueryParserService.java:223)  
> at  
> org.elasticsearch.search.query.QueryParseElement.parse(QueryParseElement.java:33)  
> at  
> org.elasticsearch.search.SearchService.parseSource(SearchService.java:545)

---

<div class="post-metadata">

### Author: ![rae1creve](https://avatars.discourse-cdn.com/v4/letter/r/a87d85/32.png) [@rae1creve](https://discuss.elastic.co/u/rae1creve)
#### Post date: [November 16, 2012, 12:22am UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/5 "2012-11-16T00:22:36Z")

</div>

Hi Clint,

I'm not sure this is working as expected. I would assume an Index query or Index filter would only be applied to the indicated index. In the query below, we are filtering on a nested field that exists in one index ("ideas") and does not exist in the other index ("documents").

Yet, we still get the following error for all document results

QueryParsingException[[documents] [nested] failed to find nested object under path [authors]];

Our query JSON is as follows:

{  
"query": {  
"filtered": {  
"query": {  
"custom\_score": {  
"query": {  
"dis\_max": {  
"queries": [  
{  
"filtered": {  
"query": {  
"multi\_match": {  
"query": "biology",  
"fields": [  
"name^1.0",  
"network.name^1.0"  
],  
"operator": "AND"  
}  
},  
"filter": {  
"term": {  
"doc\_type": "deck"  
}  
}  
}  
},  
{  
"filtered": {  
"query": {  
"multi\_match": {  
"query": "biology",  
"fields": [  
"name^1.0",  
"body\_search^1.0",  
"network.name^1.0"  
],  
"operator": "AND"  
}  
},  
"filter": {  
"term": {  
"doc\_type": "file"  
}  
}  
}  
},  
{  
"filtered": {  
"query": {  
"multi\_match": {  
"query": "biology",  
"fields": [  
"term^1.0"  
],  
"operator": "AND"  
}  
},  
"filter": {  
"type": {  
"value": "idea"  
}  
}  
}  
}  
]  
}  
},  
"script": "(\_score / 3) \* (1.0 + (doc['views'].value == 0 ? 0 : log10(doc['views'].value))) \* (1.0 + (doc['\_type'].value == 'idea' ? ((doc['term\_media'].empty ? 0 : 0.2) + (doc['definition\_media'].empty ? 0 : 0.2)) : (0.0) ))\* (1.0 + (0.2 \* (doc['time\_updated'].date.millis - 1167631200000) / (time() - 1167631200000)))",  
"lang": "mvel"  
}  
},  
"filter": {  
"indices": {  
"filter": {  
"and": {  
"filters": [  
{  
"type": {  
"value": "idea"  
}  
},  
{  
"and": {  
"filters": [  
{  
"nested": {  
"filter": {  
"and": {  
"filters": [  
{  
"term": {  
"authors.network\_id": [  
1793  
]  
}  
}  
]  
}  
},  
"path": "authors"  
}  
}  
]  
}  
}  
]  
}  
},  
"indices": [  
"ideas"  
],  
"no\_match\_filter": {  
"or": {  
"filters": [  
{  
"and": {  
"filters": [  
{  
"term": {  
"doc\_type": "file"  
}  
},  
{  
"and": {  
"filters": [  
{  
"term": {  
"network.network\_id": [  
1793  
]  
}  
}  
]  
}  
}  
]  
}  
},  
{  
"and": {  
"filters": [  
{  
"term": {  
"doc\_type": "deck"  
}  
},  
{  
"and": {  
"filters": [  
{  
"term": {  
"network.network\_id": [  
1793  
]  
}  
}  
]  
}  
}  
]  
}  
}  
]  
}  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

### Author: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [November 16, 2012, 8:41am UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/6 "2012-11-16T08:41:18Z")

</div>

On Thu, 2012-11-15 at 16:22 -0800, rae1creve wrote:

> Hi Clint,
> 
> I'm not sure this is working as expected. I would assume an Index query or  
> Index filter would only be applied to the indicated index. In the query  
> below, we are filtering on a nested field that exists in one index ("ideas")  
> and does not exist in the other index ("documents").

Looks like a bug to me. I've opened this issue:

> <https://github.com/elastic/elasticsearch/issues/2416>
>
> A used in the forum is trying to apply a nested filter to just one index, while …querying more than one index, some of which don't have the nested mapping.
> 
> The query is complaining about a missing nested mapping, but on the indices to which the query should not apply.
> 
> Create two indices: \`test\_1\` with a nested mapping, and \`test\_2\` without a nested mapping:
> 
> \`\`\`
> curl -XPUT 'http://127.0.0.1:9200/test\_1/?pretty=1' -d '
> {
> "mappings" : {
> "foo" : {
> "properties" : {
> "authors" : {
> "type" : "nested",
> "properties" : {
> "name" : {
> "type" : "string"
> }
> }
> },
> "title" : {
> "type" : "string"
> }
> }
> }
> }
> }
> '
> 
> curl -XPUT 'http://127.0.0.1:9200/test\_2/?pretty=1' -d '
> {
> "mappings" : {
> "bar" : {
> "properties" : {
> "title" : {
> "type" : "string"
> }
> }
> }
> }
> }
> '
> \`\`\`
> 
> Index some data:
> 
> \`\`\`
> curl -XPOST 'http://127.0.0.1:9200/test\_1/foo?pretty=1' -d '
> {
> "author" : {
> "name" : "john smith"
> },
> "title" : "test 1 doc"
> }
> '
> 
> curl -XPOST 'http://127.0.0.1:9200/test\_2/bar?pretty=1' -d '
> {
> "title" : "test 2 doc"
> }
> '
> \`\`\`
> 
> Query \`test\_1\` and \`test\_2\` but limit the nested filter to just \`test\_1\`:
> 
> \`\`\`
> curl -XGET 'http://127.0.0.1:9200/test\_1%2Ctest\_2/\_search?pretty=1' -d '
> {
> "query" : {
> "filtered" : {
> "filter" : {
> "indices" : {
> "no\_match\_filter" : "none",
> "filter" : {
> "nested" : {
> "filter" : {
> "term" : {
> "author.name" : "john"
> }
> },
> "path" : "author"
> }
> },
> "indices" : \[
> "test\_1"
> \]
> }
> },
> "query" : {
> "match" : {
> "title" : "test"
> }
> }
> }
> }
> }
> '
> \`\`\`
> 
> Throws this error:
> 
> \`\`\`
> SearchPhaseExecutionException\[Failed to execute phase \[query\], total failure; shardFailures {\[Yit05d94RgiUwMg9vzMOgw\]\[test\_1\]\[1\]: SearchParseException\[\[test\_1\]\[1\]: from\[-1\],size\[-1\]: Parse Failure \[Failed to parse source \[{
> "query" : {
> "filtered" : {
> "filter" : {
> "indices" : {
> "no\_match\_filter" : "none",
> "filter" : {
> "nested" : {
> "filter" : {
> "term" : {
> "author.name" : "john"
> }
> },
> "path" : "author"
> }
> },
> "indices" : \[
> "test\_1"
> \]
> }
> },
> "query" : {
> "match" : {
> "title" : "test"
> }
> }
> }
> }
> }
> \`\`\`

clint

--

---

<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, 3:04am UTC](https://discuss.elastic.co/t/how-to-avoid-failed-to-find-nested-object-under-path-when-searching-over-many-indexes/7804/7 "2017-07-06T03:04:00Z")

</div>


