Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
apalchys opened this issue Jan 9, 2024 · 7 comments
Open

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

apalchys opened this issue Jan 9, 2024 · 7 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers Search Search query, autocomplete ...etc

Comments

@apalchys
Copy link

apalchys commented Jan 9, 2024

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
elastic/elasticsearch#64609

@apalchys apalchys added bug Something isn't working untriaged labels Jan 9, 2024
@github-actions github-actions bot added the Search Search query, autocomplete ...etc label Jan 9, 2024
@msfroh msfroh added good first issue Good for newcomers and removed untriaged labels Jan 10, 2024
@msfroh
Copy link
Collaborator

msfroh commented Jan 10, 2024

@apalchys -- Are you able to create a failing integration test for this issue? Sounds like it's very consistently reproducible.

@Luci-MG
Copy link
Contributor

Luci-MG commented Jan 15, 2024

@msfroh -- I'm interested in contributing & raise PR to its resolution

@apalchys
Copy link
Author

@Luci-MG thank you. let me know if I could help.

@msfroh is it right file to learn how to write integration test for this bug?

https://github.com/opensearch-project/OpenSearch/blob/main/server/src/internalClusterTest/java/org/opensearch/search/query/ExistsIT.java

@msfroh
Copy link
Collaborator

msfroh commented Jan 24, 2024

@apalchys -- That's one place where you can add an integration test. You can also add a case to one of the REST yaml tests: https://github.com/opensearch-project/OpenSearch/blob/main/rest-api-spec/src/main/resources/rest-api-spec/test/search/160_exists_query.yml.

I personally find the yaml tests easier to write, since you just need to specify a series of REST requests, but either way works.

@Luci-MG -- I've assigned the issue to you. Let me know if you need any help.

Thanks!

@Luci-MG
Copy link
Contributor

Luci-MG commented Jan 27, 2024

@msfroh Raised PR for the FIX please checkout and let me know if this needs any changes, Thank you :)

@sandeshkr419
Copy link
Contributor

Closing the issue as the fix is merged #12048 #13006

@dblock
Copy link
Member

dblock commented Aug 12, 2024

Would be awesome if someone checked https://github.com/opensearch-project/opensearch-api-specification for whether it describes search_as_you_type properly and added an example (we plan to use those in docs).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Search Search query, autocomplete ...etc
Projects
Status: Done
Development

No branches or pull requests

6 participants
@msfroh @dblock @apalchys @sandeshkr419 @Luci-MG and others