Skip to content

Unified highlighter with bool query containing nested query throws illegal argument exception #106693

@niktrk

Description

@niktrk

Elasticsearch Version

8.10+

Installed Plugins

No response

Java Version

bundled

OS Version

bundled

Problem Description

When running a bool query containing nested query with unified highlighting we sometimes get illegal argument exception.
Query:

{
  "query": {
    "bool": {
      "must": {
        "match": {
          "subject": {
            "query": "bike"
          }
        }
      },
      "must_not": {
        "nested": {
          "query": {
            "match": {
              "attachments.name": {
                "query": "invite"
              }
            }
          },
          "path": "attachments"
        }
      }
    }
  },
  "highlight": {
    "require_field_match": true,
    "fields": {
      "subject": {
        "type": "unified"
      }
    }
  }
}

Error:

"type": "illegal_argument_exception",
"reason": "Reader FilterLeafReader(FilterLeafReader(FilterLeafReader(FieldUsageTrackingLeafReader(reader=FilterLeafReader(_gp(8.11.1):C3054/2:[diagnostics={java.runtime.version=11.0.10+9-LTS, mergeFactor=2, os.arch=x86_64, source=merge, java.vendor=Amazon.com Inc., os.version=10.16, mergeMaxNumSegments=-1, java.version=11.0.10, java.vm.version=11.0.10+9-LTS, lucene.version=8.11.1, timestamp=1697821346583, os=Mac OS X}]:[attributes={Lucene87StoredFieldsFormat.mode=BEST_SPEED}]:fieldInfosGen=1:dvGen=1 :softDel=2 :id=9mvdr58lxesb0l6jrs63zxpmt))))) does not support caching"

We have done some investigating and testing:

Steps to Reproduce

We have tried creating minimal set of steps for reproducing this but we failed. Query posted above is indeed minimal one that produced an error. In the process we learned that query itself is not enough to reproduce it, indexed data set is also relevant. Both fields hit by the query "subject" and "attachments.name" are mapped as following:

"type": "text",
"term_vector": "with_positions_offsets"

Also, if "must_not" part of the query contains a query which hits no documents we don't get the error, only if some documents are hit by that query error appears.

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>bugTeam:SearchMeta label for search team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions