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

Fix case insensitive and escaped query on wildcard #16827

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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
Loading