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] Wildcard field type causing errors in query with "fields" wildcard #15215

Closed
Calebjh opened this issue Aug 12, 2024 · 9 comments
Closed
Assignees
Labels
bug Something isn't working Search Search query, autocomplete ...etc

Comments

@Calebjh
Copy link

Calebjh commented Aug 12, 2024

Describe the bug

When trying to incorporate the new wildcard field type into some existing index/query structures, I am encountering an error when using a wildcard in a fields query block.

"reason": "failed to create query: Index 0 out of bounds for length 0",

It seems to be related to the presence of multiple top level properties (my existing data has info split between doc.* fields and metadata.* fields, and when I create a test index with only doc.* fields it seems to work).

Related component

Search

To Reproduce

  1. Create an index with more than one subproperty (possibly the incorrect terminology)
PUT test_index
{
  "mappings": {
    "dynamic": "strict",
    "properties": {
      "doc": {
        "properties": {
          "summary": {
            "type": "wildcard"
          }
        }
      },
      "metadata": {
        "properties": {
          "status": {
            "type": "long"
          }
        }
      }
    }
  }
}
  1. Make a query against the index with wildcard in the fields block
GET test_index/_search
{
  "from": 0,
  "query": {
    "query_string": {
      "analyze_wildcard": true,
      "fields": [
        "doc.*"
      ],
      "query": "*foo*"
    }
  }
}
  1. Receive error response
{
  "error": {
    "root_cause": [
      {
        "type": "query_shard_exception",
        "reason": "failed to create query: Index 0 out of bounds for length 0",
        "index": "test_index",
        "index_uuid": "jkSC-uIXStyOy2db_3ZLtA"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "test_index",
        "node": "GTGj9ZMiT-WUbQTyOtkTdw",
        "reason": {
          "type": "query_shard_exception",
          "reason": "failed to create query: Index 0 out of bounds for length 0",
          "index": "test_index",
          "index_uuid": "jkSC-uIXStyOy2db_3ZLtA",
          "caused_by": {
            "type": "string_index_out_of_bounds_exception",
            "reason": "Index 0 out of bounds for length 0"
          }
        }
      }
    ]
  },
  "status": 400
}

Expected behavior

If the type is not a wildcard, such as a keyword, the query completes with no errors. I would expect either an informative error if this query structure is incompatible with wildcards for some reason, or (ideally) for the query to just work like it does with non-wildcard fields.

Additional Details

Plugins
Please list all plugins currently enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Host/Environment (please complete the following information):
Querying OpenSearch 2.15 and 2.16 running as a docker container from an opensearch-dashboards 2.15 interface also running via Docker.

Additional context
Add any other context about the problem here.

@Calebjh Calebjh added bug Something isn't working untriaged labels Aug 12, 2024
@github-actions github-actions bot added the Search Search query, autocomplete ...etc label Aug 12, 2024
@hasnain2808
Copy link
Contributor

If we accept this bug in the weekly search triage meeting, I would like to work on this

@mch2
Copy link
Member

mch2 commented Aug 14, 2024

Thanks @Calebjh for reporting and for volunteering @hasnain2808 have assigned to you. @msfroh FYI.

@msfroh
Copy link
Collaborator

msfroh commented Aug 14, 2024

@msfroh FYI.

Yup! Sounds like a bug. I'm curious about whether the bug is in the wildcard on the fields block or if it's because of the query_string query. (I don't remember if I added test cases for query_string queries on wildcard fields.)

@hasnain2808
Copy link
Contributor

@Calebjh

It seems to be related to the presence of multiple top level properties (my existing data has info split between doc.* fields and metadata.* fields, and when I create a test index with only doc.* fields it seems to work).

It fails even for a test index with only doc.* fields

Screenshot 2024-08-20 at 9 30 37 PM image

@Calebjh
Copy link
Author

Calebjh commented Aug 22, 2024

@hasnain2808 Interesting. I thought that I tested both ways and found it worked for one and not the other, but perhaps I was trying too many different variations and got my test cases mixed up (I was just making the different adjustments by hand to try and see what was causing the failure).
Should I make any adjustment to the original description to correct that, or is the extra clarification down here adequate?

@hasnain2808
Copy link
Contributor

@hasnain2808 Interesting. I thought that I tested both ways and found it worked for one and not the other, but perhaps I was trying too many different variations and got my test cases mixed up (I was just making the different adjustments by hand to try and see what was causing the failure). Should I make any adjustment to the original description to correct that, or is the extra clarification down here adequate?

I retested
it fails for both

we can add a new section with a date and add this as a new update/ new finding

@hasnain2808
Copy link
Contributor

hasnain2808 commented Sep 16, 2024

triage:

issue replicates on 2.15, 2.16 but does not replicate on 3.x or 2.x

wild card fields were added to 2.15

Looks like this PR solved the issue and we can close this

Specifically this line

https://github.com/opensearch-project/OpenSearch/pull/15737/files#diff-4fef7944375affd51ec9418a4efbb5c48fb8820dffde9c3ad8f63fe5efbd312dR476

cc: @msfroh @mch2 @Calebjh

@msfroh
Copy link
Collaborator

msfroh commented Sep 16, 2024

Oh, nice! Thanks @hasnain2808 for working to reproduce.

It looks like I merged that PR after the 2.17 freeze, but it should be fixed in 2.18.

Special thanks to @HUSTERGS, who is fixing all the wildcard field bugs these days.

@dblock
Copy link
Member

dblock commented Sep 17, 2024

Fixed in #15737

@dblock dblock closed this as completed Sep 17, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Search Project Board Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Search Search query, autocomplete ...etc
Projects
Archived in project
Development

No branches or pull requests

5 participants