opensearch-project/OpenSearch

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

Open

#11.821 aberto em 9 de jan. de 2024

Ver no GitHub
 (8 comments) (0 reactions) (1 assignee)Java (1.505 forks)batch import
Searchbuggood first issue

Métricas do repositório

Stars
 (8.123 stars)
Métricas de merge de PR
 (Mesclagem média 5d 9h) (266 fundiu PRs em 30d)

Description

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

Guia do colaborador