opensearch-project/OpenSearch

[BUG] Exists query fails if object has "search_as_you_type" field

Open

#11.821 geöffnet am 9. Jan. 2024

Auf GitHub ansehen
 (8 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Java (1.505 Forks)batch import
Searchbuggood first issue

Repository-Metriken

Stars
 (8.123 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 9h) (266 gemergte PRs in 30 T)

Beschreibung

Describe the bug

The "exists" query on an object field will fail when a "search_as_you_type" field is nested under that object. See step to reproduce for an example.

Related component

Search

To Reproduce

Queries:

PUT bug_exists
{
  "mappings": {
    "properties": {
      "user": {
        "properties": {
          "name": {
            "type": "keyword",
            "normalizer": "lowercase",
            "fields": {
              "lookup": {
                "type": "search_as_you_type",
                "doc_values": false,
                "max_shingle_size": 3
              }
            }
          }
        }
      }
    }
  }
}

POST bug_exists/_doc
{
  "user": {
    "name": "foo"
  }
}

POST bug_exists/_search
{
  "query": {
    "exists": {
      "field": "user"
    }
  }
}

Executing search query gives the following error:

{
  "error": {
    "root_cause": [
      {
        "type": "unsupported_operation_exception",
        "reason": "unsupported_operation_exception: null"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "bug_exists",
        "node": "vQR3k_EpTqGwm-tWhNHpJA",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to create query: null",
          "index": "bug_exists",
          "index_uuid": "2XEpnkKbSL62szsFvLvOtw",
          "caused_by": {
            "type": "unsupported_operation_exception",
            "reason": "unsupported_operation_exception: null"
          }
        }
      }
    ],
    "caused_by": {
      "type": "unsupported_operation_exception",
      "reason": "unsupported_operation_exception: null"
    }
  },
  "status": 400
}

Expected behavior

The following query should not fail and return the document

POST bug_exists/_search
{
  "query": {
    "exists": {
      "field": "user"
    }
  }
}

Additional Details

Host/Environment (please complete the following information):

  • AWS OpenSearch 2.11

Additional context The same bug in ElasticSearch fixed in 8.0 https://github.com/elastic/elasticsearch/issues/64609

Contributor Guide