searchkit / searchkit

Search UI for Elasticsearch & Opensearch. Compatible with Algolia's Instantsearch and Autocomplete components. React & Vue support
http://www.searchkit.co/docs
Apache License 2.0
4.77k stars 443 forks source link

createRegexQuery only transforms lowercase to uppercase and not the inverse #1378

Open mattc-cogapp opened 3 months ago

mattc-cogapp commented 3 months ago

The problem

When building the regular expression for a facet query, createRegexQuery runs the following check, which takes any lowercase letters and adds an uppercase equivalent in a group to allow for case insensitivity. However this does not do the inverse. For example, the following transformation works as expected:

hello => [hH][eE][lL][lL][oO]

But the following don't do the same thing for uppercase to lowercase:

Input Expectation Actual
Hey [hH][eE][yY] H[eE][yY]
HeY [hH][eE][yY] H[eE]Y
HEY [hH][eE][yY] HEY

It feels like whatever is input here should be converted into upper and lower case to account for the lack of case sensitivity in a term query.

I'm happy to provide a PR to amend the createRegexQuery function if this is an issue that you'd be open to having fixed?

Environment

Details

See above

Code To Reproduce Issue

  1. Create an index with a single field
{
  "mappings": {
    "title": {
      "type": "text",
      "fields": {
        "keyword": {
          "type": "keyword",
          "ignore_above": 256
        }
      }
    }
  }
}
  1. Add a document with the title of "Mario"
  2. Add a RefinementList component looking at the field
  3. Mario and mario return results
  4. MaRiO and MARIO do not return results
joemcelroy commented 3 months ago

happy to accept a pr for all of these issues with regex search.