Skip to content

Commit 9f8ea08

Browse files
opensearch-trigger-bot[bot]github-actions[bot]gesong.samuelmsfroh
authored
Fix case insensitive and escaped query on wildcard (#16827) (#17001)
* fix case insensitive and escaped query on wildcard * add changelog --------- (cherry picked from commit 5afb92f) Signed-off-by: gesong.samuel <gesong.samuel@bytedance.com> Signed-off-by: Michael Froh <froh@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: gesong.samuel <gesong.samuel@bytedance.com> Co-authored-by: Michael Froh <froh@amazon.com>
1 parent 6698ccc commit 9f8ea08

File tree

3 files changed

+213
-31
lines changed

3 files changed

+213
-31
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2424
### Removed
2525

2626
### Fixed
27+
- Fix case insensitive and escaped query on wildcard ([#16827](https://github.com/opensearch-project/OpenSearch/pull/16827))
2728

2829
### Security
2930

rest-api-spec/src/main/resources/rest-api-spec/test/search/270_wildcard_fieldtype_queries.yml

+125-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ setup:
6262
id: 7
6363
body:
6464
my_field: "ABCD"
65+
- do:
66+
index:
67+
index: test
68+
id: 8
69+
body:
70+
my_field: "*"
71+
72+
- do:
73+
index:
74+
index: test
75+
id: 9
76+
body:
77+
my_field: "\\*"
6578
- do:
6679
indices.refresh: {}
6780

@@ -223,7 +236,7 @@ setup:
223236
wildcard:
224237
my_field:
225238
value: "*"
226-
- match: { hits.total.value: 6 }
239+
- match: { hits.total.value: 8 }
227240
---
228241
"regexp match-all works":
229242
- do:
@@ -234,7 +247,7 @@ setup:
234247
regexp:
235248
my_field:
236249
value: ".*"
237-
- match: { hits.total.value: 6 }
250+
- match: { hits.total.value: 8 }
238251
---
239252
"terms query on wildcard field matches":
240253
- do:
@@ -270,3 +283,113 @@ setup:
270283
- match: { hits.total.value: 2 }
271284
- match: { hits.hits.0._id: "5" }
272285
- match: { hits.hits.1._id: "7" }
286+
---
287+
"case insensitive regexp query on wildcard field":
288+
- do:
289+
search:
290+
index: test
291+
body:
292+
query:
293+
regexp:
294+
my_field:
295+
value: "AbCd"
296+
- match: { hits.total.value: 1 }
297+
- match: { hits.hits.0._id: "5" }
298+
- do:
299+
search:
300+
index: test
301+
body:
302+
query:
303+
regexp:
304+
my_field:
305+
value: "AbCd"
306+
case_insensitive: true
307+
- match: { hits.total.value: 2 }
308+
- match: { hits.hits.0._id: "5" }
309+
- match: { hits.hits.1._id: "7" }
310+
---
311+
"wildcard query works on values contains escaped characters":
312+
- do:
313+
search:
314+
index: test
315+
body:
316+
query:
317+
wildcard:
318+
my_field:
319+
value: "\\*"
320+
- match: { hits.total.value: 1 }
321+
- match: { hits.hits.0._id: "8" }
322+
323+
- do:
324+
search:
325+
index: test
326+
body:
327+
query:
328+
wildcard:
329+
my_field:
330+
value: "\\\\\\*"
331+
- match: { hits.total.value: 1 }
332+
- match: { hits.hits.0._id: "9" }
333+
---
334+
"regexp query works on values contains escaped characters":
335+
- do:
336+
search:
337+
index: test
338+
body:
339+
query:
340+
regexp:
341+
my_field:
342+
value: "\\*"
343+
- match: { hits.total.value: 1 }
344+
- match: { hits.hits.0._id: "8" }
345+
346+
- do:
347+
search:
348+
index: test
349+
body:
350+
query:
351+
regexp:
352+
my_field:
353+
value: "\\\\\\*"
354+
- match: { hits.total.value: 1 }
355+
- match: { hits.hits.0._id: "9"}
356+
---
357+
"term query contains escaped characters":
358+
- do:
359+
search:
360+
index: test
361+
body:
362+
query:
363+
term:
364+
my_field: "\\*"
365+
- match: { hits.total.value: 1 }
366+
- match: { hits.hits.0._id: "9" }
367+
368+
- do:
369+
search:
370+
index: test
371+
body:
372+
query:
373+
term:
374+
my_field: "*"
375+
- match: { hits.total.value: 1 }
376+
- match: { hits.hits.0._id: "8"}
377+
---
378+
"terms query contains escaped characters":
379+
- do:
380+
search:
381+
index: test
382+
body:
383+
query:
384+
terms: { my_field: ["*"] }
385+
- match: { hits.total.value: 1 }
386+
- match: { hits.hits.0._id: "8" }
387+
388+
- do:
389+
search:
390+
index: test
391+
body:
392+
query:
393+
terms: { my_field: [ "\\*" ] }
394+
- match: { hits.total.value: 1 }
395+
- match: { hits.hits.0._id: "9" }

0 commit comments

Comments
 (0)