Inner hits in a double nested query fine in ES 7.7, but not working in 7.10

I have an index (sentences) where documents contain two kinds of nested objects, one (ana) inside the other (words). In my queries, I use two inner_hits keys to highlight the matches. This worked fine in 5.6 and still works in 7.7, but in 7.10, the innermost inner_hits breaks down everything with a search phase execution exception.

This is my query:

{
 "query": {
  "bool": {
   "must": [{
    "nested": {
     "path": "words",
     "query": {
      "constant_score": {
       "filter": {
        "bool": {
         "must": [{
          "match": {
           "words.wtype": "word"
          }
         }, {
          "nested": {
           "path": "words.ana",
           "query": {
            "constant_score": {
             "filter": {
              "match": {
               "words.ana.gr.pos": "V"
              }
             },
             "boost": 1
            }
           },
           "score_mode": "sum",
           "inner_hits": {}
          }
         }]
        }
       },
       "boost": 1
      }
     },
     "score_mode": "sum",
     "inner_hits": {}
    }
   }],
   "filter": [{
    "term": {
     "lang": {
      "value": 0
     }
    }
   }]
  }
 },
 "size": 1,
 "from": 0,
 "aggs": {
  "agg_ndocs": {
   "cardinality": {
    "field": "doc_id"
   }
  },
  "agg_nwords": {
   "stats": {
    "script": "_score"
   }
  }
 }
}

If I delete the first inner_hits, then the second one works fine. Removing all this constant_score stuff does not help. Having a highlighter inside inner_hits and playing with parameters (number_of_fragments, fragment_size) does not help either. This is the error Iʼm getting:

org.elasticsearch.action.search.SearchPhaseExecutionException: all shards failed
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseFailure(AbstractSearchAsyncAction.java:568) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:324) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.onPhaseDone(AbstractSearchAsyncAction.java:603) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.onShardFailure(AbstractSearchAsyncAction.java:400) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.access$100(AbstractSearchAsyncAction.java:70) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction$1.onFailure(AbstractSearchAsyncAction.java:258) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.SearchExecutionStatsCollector.onFailure(SearchExecutionStatsCollector.java:73) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.ActionListenerResponseHandler.handleException(ActionListenerResponseHandler.java:59) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.SearchTransportService$ConnectionCountingHandler.handleException(SearchTransportService.java:408) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.transport.TransportService$6.handleException(TransportService.java:640) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.transport.TransportService$ContextRestoreResponseHandler.handleException(TransportService.java:1181) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:1290) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:1264) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.transport.TaskTransportChannel.sendResponse(TaskTransportChannel.java:61) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.transport.TransportChannel.sendErrorResponse(TransportChannel.java:56) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.support.ChannelActionListener.onFailure(ChannelActionListener.java:51) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.ActionRunnable.onFailure(ActionRunnable.java:88) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:39) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:44) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:737) [elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-7.10.0.jar:7.10.0]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
        at java.lang.Thread.run(Thread.java:834) [?:?]
Caused by: org.elasticsearch.ElasticsearchException$1: Index: 5, Size: 1
        at org.elasticsearch.ElasticsearchException.guessRootCauses(ElasticsearchException.java:644) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.search.AbstractSearchAsyncAction.executeNextPhase(AbstractSearchAsyncAction.java:322) [elasticsearch-7.10.0.jar:7.10.0]
        ... 22 more
Caused by: java.lang.IndexOutOfBoundsException: Index: 5, Size: 1
        at java.util.Collections$SingletonList.get(Collections.java:4849) ~[?:?]
        at org.elasticsearch.search.fetch.FetchPhase.prepareNestedHitContext(FetchPhase.java:458) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.FetchPhase.prepareHitContext(FetchPhase.java:298) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:156) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.subphase.InnerHitsPhase.hitExecute(InnerHitsPhase.java:89) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.subphase.InnerHitsPhase.access$000(InnerHitsPhase.java:40) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.subphase.InnerHitsPhase$1.process(InnerHitsPhase.java:62) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:167) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.subphase.InnerHitsPhase.hitExecute(InnerHitsPhase.java:89) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.subphase.InnerHitsPhase.access$000(InnerHitsPhase.java:40) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.subphase.InnerHitsPhase$1.process(InnerHitsPhase.java:62) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:167) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.SearchService.executeFetchPhase(SearchService.java:462) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:438) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.SearchService.access$500(SearchService.java:141) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.search.SearchService$2.lambda$onResponse$0(SearchService.java:401) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:58) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:73) ~[elasticsearch-7.10.0.jar:7.10.0]
        at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-7.10.0.jar:7.10.0]
        ... 6 more

Here is the mapping I use for my sentences index:

{
    "mappings": {
      "properties": {
        "prev_id": {
          "type": "integer"
        },
        "next_id": {
          "type": "integer"
        },
        "doc_id": {
          "type": "integer"
        },
        "text": {
          "type": "text"
        },
        "lang": {
          "type": "byte"
        },
        "words": {
          "type": "nested",
          "properties": {
            "wf": {
              "type": "text",
              "fielddata": true,
              "analyzer": "wf_analyzer"
            },
            "wf_display": {
              "type": "text",
              "index": false
            },
            "wtype": {
              "type": "keyword"
            },
            "lang": {
              "type": "byte"
            },
            "sentence_index": {
              "type": "short"
            },
            "sentence_index_neg": {
              "type": "short"
            },
            "sids": {
              "type": "integer",
              "index": false
            },
            "n_ana": {
              "type": "byte"
            },
            "ana": {
              "type": "nested",
              "properties": {
                "lex": {
                  "type": "text",
                  "fielddata": true,
                  "analyzer": "wf_analyzer"
                },
                "gloss_index": {
                  "type": "text",
                  "analyzer": "gloss_analyzer"
                },
                "gloss": {
                  "type": "text",
                  "index": false
                },
                "gr.pos": {
                  "type": "keyword"
                }
              }
            }
          }
        },
        "n_words": {
          "type": "short"
        }
      }
    },
    "settings": {
      "analysis": {
        "analyzer": {
          "wf_analyzer": {
            "type": "pattern",
            "pattern": "[.\n()\\[\\]/]",
            "lowercase": true
          },
          "gloss_analyzer": {
            "type": "pattern",
            "pattern": " ",
            "lowercase": true
          }
        }
      }
    }
}

And here is the only document I put there:

{
 "_index": "sentences",
 "_id": 0,
 "_source": {
  "text": "\n[LV] Ja, šʼabašʼ karišʼkom.",
  "lang": 0,
  "meta": {
   "speaker": "LV",
   "sent_analyses": "complete",
   "speaker_kw": "LV",
   "sent_analyses_kw": "complete"
  },
  "words": [{
   "off_start": 0,
   "off_end": 1,
   "wf": "\n",
   "wtype": "punct"
  }, {
   "off_start": 1,
   "off_end": 5,
   "wf": "[LV]",
   "wtype": "punct"
  }, {
   "off_start": 6,
   "wf": "Ja",
   "wtype": "word",
   "off_end": 8,
   "ana": [{
    "lex": "ja",
    "gr.pos": "PART",
    "parts": "ja",
    "gloss": "STEM",
    "gloss_index": "STEM{ja}-"
   }],
   "n_ana": 1,
   "w_id": "w0",
   "l_id": "l1"
  }, {
   "off_start": 8,
   "wf": ",",
   "wtype": "punct",
   "off_end": 9
  }, {
   "off_start": 10,
   "wf": "šʼabašʼ",
   "wtype": "word",
   "off_end": 17,
   "ana": [{
    "lex": "šʼabašʼ",
    "gr.pos": "INTERJ",
    "parts": "šʼabašʼ",
    "gloss": "STEM",
    "gloss_index": "STEM{šʼabašʼ}-"
   }],
   "n_ana": 1,
   "w_id": "w1",
   "l_id": "l2"
  }, {
   "off_start": 18,
   "wf": "karišʼkom",
   "wtype": "word",
   "off_end": 27,
   "ana": [{
    "lex": "karənə",
    "gr.pos": "V",
    "parts": "kar-išʼkom",
    "gloss": "STEM-PRS.1PL",
    "gloss_index": "STEM{kar}-PRS.1PL{išʼkom}-"
   }, {
    "lex": "karənə",
    "gr.pos": "V",
    "parts": "kar-išʼk-o-m",
    "gloss": "STEM-DETR-FUT-1PL",
    "gloss_index": "STEM{kar}-DETR{išʼk}-FUT{o}-1PL{m}-"
   }],
   "n_ana": 2,
   "w_id": "w2",
   "l_id": "l3"
  }, {
   "off_start": 27,
   "wf": ".",
   "wtype": "punct",
   "off_end": 28
  }],
  "n_words": 3,
  "doc_id": 0
 }
}

(The data I use in reality is more complex, but this simplified version does not work either.)

Am I doing something wrong, or is it a bug introduced somewhere between 7.7 and 7.10?

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