# \[nested\] failed to find nested object under path \[orders\]

**URL:** <https://discuss.elastic.co/t/nested-failed-to-find-nested-object-under-path-orders/237603>\
**Category:** Elasticsearch\
**Created:** [June 18, 2020, 9:03am UTC](https://discuss.elastic.co/t/nested-failed-to-find-nested-object-under-path-orders/237603 "2020-06-18T09:03:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravivarmakola](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@ravivarmakola](https://discuss.elastic.co/u/ravivarmakola)\
**Post date:** [June 18, 2020, 9:03am UTC](https://discuss.elastic.co/t/nested-failed-to-find-nested-object-under-path-orders/237603/1 "2020-06-18T09:03:25Z")

</div>

I am getting "[nested] failed to find nested object under path" when searching on single index and field has "type": "nested" in mappings:  
PS: I am getting response, but exception is seen on elasticsearch console.  
If I execute the query using SoapUI, i dont see an issue.  
I see this issue when invoking from Springboot application.

Elastic version: 6.8.0 (https enabled)  
Springboot: 2.2.0

Workaround found: when i use "ignore\_unmapped" : true, then the exception is not shown on console.

I am accessing elastic search with 9200 port, but in exception, i see 9300 (org.elasticsearch.transport.RemoteTransportException: [ICcYcsD][127.0.0.1:9300][indices:data/read/search[phase/dfs]])

Mapping:

```
`{"customer_orders": {"mappings": {"_doc": {"properties": {
   "firstName": {
      "type": "text",
      "fields": {"keyword": {
         "type": "keyword",
         "ignore_above": 256
      }}
   },
   "lastName": {
      "type": "text",
      "fields": {"keyword": {
         "type": "keyword",
         "ignore_above": 256
      }}
   },
   "orders": {
      "type": "nested",
      "properties": {
         "orderId": {
            "type": "text",
            "fields": {"keyword": {
               "type": "keyword",
               "ignore_above": 256
            }}
         },
         "orderName": {
            "type": "text",
            "fields": {"keyword": {
               "type": "keyword",
               "ignore_above": 256
            }}
         }
      }
   }
}}}}}`

```

Exception:

```
` [2020-06-18T10:28:55,705][DEBUG][o.e.a.s.TransportSearchAction] [ICcYcsD] [user_and_entitlement][4], node[ICcYcsDsQoCxs0ybyFbDKw], [P], s[STARTED], a[id=6HMxn-fNSLKgy7N0nVYcPw]: Failed to execute [SearchRequest{searchType=DFS_QUERY_THEN_FETCH, indices=[.security, .security-6, customer_orders, user_and_entitlement], indicesOptions=IndicesOptions[ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_aliases_to_multiple_indices=true, forbid_closed_indices=true, ignore_aliases=false, ignore_throttled=true], types=[], routing='null', preference='null', requestCache=null, scroll=null, maxConcurrentShardRequests=5, batchedReduceSize=512, preFilterShardSize=128, allowPartialSearchResults=true, localClusterAlias=null, getOrCreateAbsoluteStartMillis=-1, source={"from":0,"query":{"bool":{"must":[{"match":{"firstName":{"query":"ravi","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}}],"should":[{"match":{"firstName":{"query":"ravi","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1.0}}},{"nested":{"query":{"query_string":{"query":"22","fields":[],"type":"best_fields","default_operator":"or","max_determinized_states":10000,"enable_position_increments":true,"fuzziness":"AUTO","fuzzy_prefix_length":0,"fuzzy_max_expansions":50,"phrase_slop":0,"escape":false,"auto_generate_synonyms_phrase_query":true,"fuzzy_transpositions":true,"boost":1.0}},"path":"orders","ignore_unmapped":false,"score_mode":"max","boost":1.0,"inner_hits":{"ignore_unmapped":false,"from":0,"size":100,"version":false,"seq_no_primary_term":false,"explain":false,"track_scores":false,"_source":false,"docvalue_fields":[{"field":"orders.orderId.keyword","format":"use_field_mapping"}]}}}],"adjust_pure_negative":true,"boost":1.0}},"version":true,"_source":{"includes":[],"excludes":["orders"]}}}] lastShard [true]
org.elasticsearch.transport.RemoteTransportException: [ICcYcsD][127.0.0.1:9300][indices:data/read/search[phase/dfs]]
Caused by: org.elasticsearch.index.query.QueryShardException: failed to create query: {
  "bool" : {
    "must" : [
      {
        "match" : {
          "firstName" : {
            "query" : "ravi",
            "operator" : "OR",
            "prefix_length" : 0,
            "max_expansions" : 50,
            "fuzzy_transpositions" : true,
            "lenient" : false,
            "zero_terms_query" : "NONE",
            "auto_generate_synonyms_phrase_query" : true,
            "boost" : 1.0
          }
        }
      }
    ],
    "should" : [
      {
        "match" : {
          "firstName" : {
            "query" : "ravi",
            "operator" : "OR",
            "prefix_length" : 0,
            "max_expansions" : 50,
            "fuzzy_transpositions" : true,
            "lenient" : false,
            "zero_terms_query" : "NONE",
            "auto_generate_synonyms_phrase_query" : true,
            "boost" : 1.0
          }
        }
      },
      {
        "nested" : {
          "query" : {
            "query_string" : {
              "query" : "22",
              "fields" : [],
              "type" : "best_fields",
              "default_operator" : "or",
              "max_determinized_states" : 10000,
              "enable_position_increments" : true,
              "fuzziness" : "AUTO",
              "fuzzy_prefix_length" : 0,
              "fuzzy_max_expansions" : 50,
              "phrase_slop" : 0,
              "escape" : false,
              "auto_generate_synonyms_phrase_query" : true,
              "fuzzy_transpositions" : true,
              "boost" : 1.0
            }
          },
          "path" : "orders",
          "ignore_unmapped" : false,
          "score_mode" : "max",
          "boost" : 1.0,
          "inner_hits" : {
            "ignore_unmapped" : false,
            "from" : 0,
            "size" : 100,
            "version" : false,
            "seq_no_primary_term" : false,
            "explain" : false,
            "track_scores" : false,
            "_source" : false,
            "docvalue_fields" : [
              {
                "field" : "orders.orderId.keyword",
                "format" : "use_field_mapping"
              } ]
          } }
      } ],
    "adjust_pure_negative" : true, "boost" : 1.0
  } }
        at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:324) ~[elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.index.query.QueryShardContext.toQuery(QueryShardContext.java:307) ~[elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.search.SearchService.parseSource(SearchService.java:770) ~[elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.search.SearchService.createContext(SearchService.java:621) ~[elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:596) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:324) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.search.SearchService.access$000(SearchService.java:126) ~[elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:310) [elasticsearch-6.8.0.jar:6.8.0] at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:306) [elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.search.SearchService$4.doRun(SearchService.java:1086) [elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) [elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) [elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-6.8.0.jar:6.8.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_251] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_251]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_251] Caused by: java.lang.IllegalStateException: [nested] failed to find nested object under path [orders]
        at org.elasticsearch.index.query.NestedQueryBuilder.doToQuery(NestedQueryBuilder.java:279) ~[elasticsearch-6.8.0.jar:6.8.0]
        at org.elasticsearch.index.query.AbstractQueryBuilder.toQuery(AbstractQueryBuilder.java:105) ~[elasticsearch-6.8.0.jar:6.8.0]
        at -- omitted rest of the stack trace
```

---

<div class="post-metadata">

**Author:** ![ravivarmakola](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@ravivarmakola](https://discuss.elastic.co/u/ravivarmakola)\
**Post date:** [July 10, 2020, 2:58pm UTC](https://discuss.elastic.co/t/nested-failed-to-find-nested-object-under-path-orders/237603/2 "2020-07-10T14:58:40Z")

</div>

This can be closed. earlier i havent used the index name in specific. when index name is not used, it is search all the available indexes and it couldnt able to find the nested path in other indices. Hence failing...

`searchQuery.addIndices("customer_orders");`

resolved my issue.

---

<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:** [August 7, 2020, 2:58pm UTC](https://discuss.elastic.co/t/nested-failed-to-find-nested-object-under-path-orders/237603/3 "2020-08-07T14:58:41Z")

</div>

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