OpenSearch icon indicating copy to clipboard operation
OpenSearch copied to clipboard

[BUG] wildcard query returns nothing incorrectly when the pattern value contains capital letter

Open LantaoJin opened this issue 1 year ago • 3 comments

Describe the bug

This search query works

GET opensearch_dashboards_sample_data_ecommerce/_search
{
  "from": 0,
  "size": 200,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "wildcard": {
                  "manufacturer": {
                    "value": "tigress*",
                    "boost": 1
                  }
                }
              }
            ],
            "boost": 1
          }
        }
      ],
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "manufacturer"
    ],
    "excludes": []
  }
}

But if we change the value to Tigress* (even the real text is Tigress), it return nothing:

GET opensearch_dashboards_sample_data_ecommerce/_search
{
  "from": 0,
  "size": 200,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "wildcard": {
                  "manufacturer": {
                    "value": "Tigress*",
                    "boost": 1
                  }
                }
              }
            ],
            "boost": 1
          }
        }
      ],
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "manufacturer"
    ],
    "excludes": []
  }
}

Related component

Search

To Reproduce

  1. Go to playground dev tool
  2. Try above two queries.

Expected behavior

Return matched docs.

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):

  • OS: [e.g. iOS]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

LantaoJin avatar Jul 11 '24 03:07 LantaoJin

Want to try to write a (failing) YAML REST test?

https://github.com/opensearch-project/OpenSearch/blob/main/TESTING.md#testing-the-rest-layer

dblock avatar Jul 11 '24 20:07 dblock

@LantaoJin can you describe manufacturer field type?

kkewwei avatar Jul 13 '24 14:07 kkewwei

You can use the case_insensitive parameter

GET opensearch_dashboards_sample_data_ecommerce/_search
{
  "from": 0,
  "size": 200,
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "wildcard": {
                  "manufacturer": {
                    "value": "Tigress*",
                    "boost": 1,
                    "case_insensitive": true
                  }
                }
              }
            ],
            "boost": 1
          }
        }
      ],
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "manufacturer"
    ],
    "excludes": []
  }
}

bugmakerrrrrr avatar Aug 27 '24 08:08 bugmakerrrrrr