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] case_insensitive regexp query didn't return expected result on a wildcard field #16755

Open
n9 opened this issue Dec 2, 2024 · 2 comments
Assignees
Labels
bug Something isn't working Search Search query, autocomplete ...etc

Comments

@n9
Copy link

n9 commented Dec 2, 2024

Describe the bug

Case insensitive regexp query on a wildcard field does not work.

Related component

Search

To Reproduce

Based on #15855

  1. Create a simple index contains a wildcard field
    PUT case_test
    {
        "mappings": {
            "properties": {
                "wildcard": {
                    "type": "wildcard"
                }
            }
        }
    }
    
  1. Bulk insert documents containing capital letters
    PUT _bulk?refresh=true
    {"index": {"_index": "case_test"}}
    {"wildcard": "TtAa"}
    {"index": {"_index": "case_test"}}
    {"wildcard": "ttaa"}
    {"index": {"_index": "case_test"}}
    {"wildcard": "TTAA"}
    
  1. Perform regexp search on the wildcard field with case_insensitive set to true.

    POST case_test/_search
    {
        "query": {
            "regexp": {
                "wildcard": {
                    "value": "TtAa",
                    "case_insensitive": true
                }
            }
        }
    }
    
  2. Check results

Expected behavior

All documents should be returned, but not.

Additional Details

Host/Environment (please complete the following information):

  • Version 2.18.0
@n9 n9 added bug Something isn't working untriaged labels Dec 2, 2024
@github-actions github-actions bot added the Search Search query, autocomplete ...etc label Dec 2, 2024
@msfroh
Copy link
Collaborator

msfroh commented Dec 2, 2024

@n9 -- Thank you! You are correct. This is a bug.

The problem here is this line, which should look more like this block. That is, if the case_insensitive flag is set, we should generate a case-insensitive term query using AutomatonQueries.

Are you willing to contribute a fix? Alternatively, would you be willing to contribute a failing test case to https://github.com/opensearch-project/OpenSearch/blob/aaa92aeeb75a745ee7b058cc4b30b734e861cfc4/rest-api-spec/src/main/resources/rest-api-spec/test/search/270_wildcard_fieldtype_queries.yml ?

@msfroh
Copy link
Collaborator

msfroh commented Dec 2, 2024

See also my comment over at #16754 (comment). I think we could address both of these issues with some refactoring to take everything down the regexp path and make sure that one path works well.

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
Status: 🆕 New
Development

No branches or pull requests

3 participants