Skip to content

Commit

Permalink
Fix case insensitive and escaped query on wildcard (#16827)
Browse files Browse the repository at this point in the history
* fix case insensitive and escaped query on wildcard

Signed-off-by: gesong.samuel <[email protected]>

* add changelog

Signed-off-by: gesong.samuel <[email protected]>

---------

Signed-off-by: gesong.samuel <[email protected]>
Signed-off-by: Michael Froh <[email protected]>
Co-authored-by: gesong.samuel <[email protected]>
Co-authored-by: Michael Froh <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2025
1 parent 8191de8 commit 5afb92f
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 31 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Bound the size of cache in deprecation logger ([16702](https://github.com/opensearch-project/OpenSearch/issues/16702))
- Ensure consistency of system flag on IndexMetadata after diff is applied ([#16644](https://github.com/opensearch-project/OpenSearch/pull/16644))
- Skip remote-repositories validations for node-joins when RepositoriesService is not in sync with cluster-state ([#16763](https://github.com/opensearch-project/OpenSearch/pull/16763))
- Fix case insensitive and escaped query on wildcard ([#16827](https://github.com/opensearch-project/OpenSearch/pull/16827))
- Fix _list/shards API failing when closed indices are present ([#16606](https://github.com/opensearch-project/OpenSearch/pull/16606))
- Fix remote shards balance ([#15335](https://github.com/opensearch-project/OpenSearch/pull/15335))
- Always use `constant_score` query for `match_only_text` field ([#16964](https://github.com/opensearch-project/OpenSearch/pull/16964))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ setup:
id: 7
body:
my_field: "ABCD"
- do:
index:
index: test
id: 8
body:
my_field: "*"

- do:
index:
index: test
id: 9
body:
my_field: "\\*"
- do:
indices.refresh: {}

Expand Down Expand Up @@ -223,7 +236,7 @@ setup:
wildcard:
my_field:
value: "*"
- match: { hits.total.value: 6 }
- match: { hits.total.value: 8 }
---
"regexp match-all works":
- do:
Expand All @@ -234,7 +247,7 @@ setup:
regexp:
my_field:
value: ".*"
- match: { hits.total.value: 6 }
- match: { hits.total.value: 8 }
---
"terms query on wildcard field matches":
- do:
Expand Down Expand Up @@ -270,3 +283,113 @@ setup:
- match: { hits.total.value: 2 }
- match: { hits.hits.0._id: "5" }
- match: { hits.hits.1._id: "7" }
---
"case insensitive regexp query on wildcard field":
- do:
search:
index: test
body:
query:
regexp:
my_field:
value: "AbCd"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "5" }
- do:
search:
index: test
body:
query:
regexp:
my_field:
value: "AbCd"
case_insensitive: true
- match: { hits.total.value: 2 }
- match: { hits.hits.0._id: "5" }
- match: { hits.hits.1._id: "7" }
---
"wildcard query works on values contains escaped characters":
- do:
search:
index: test
body:
query:
wildcard:
my_field:
value: "\\*"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "8" }

- do:
search:
index: test
body:
query:
wildcard:
my_field:
value: "\\\\\\*"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "9" }
---
"regexp query works on values contains escaped characters":
- do:
search:
index: test
body:
query:
regexp:
my_field:
value: "\\*"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "8" }

- do:
search:
index: test
body:
query:
regexp:
my_field:
value: "\\\\\\*"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "9"}
---
"term query contains escaped characters":
- do:
search:
index: test
body:
query:
term:
my_field: "\\*"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "9" }

- do:
search:
index: test
body:
query:
term:
my_field: "*"
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "8"}
---
"terms query contains escaped characters":
- do:
search:
index: test
body:
query:
terms: { my_field: ["*"] }
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "8" }

- do:
search:
index: test
body:
query:
terms: { my_field: [ "\\*" ] }
- match: { hits.total.value: 1 }
- match: { hits.hits.0._id: "9" }
Loading

0 comments on commit 5afb92f

Please sign in to comment.