Skip to content

Commit f82a1eb

Browse files
author
gesong.samuel
committed
add rolling upgrade test for wildcard field
Signed-off-by: gesong.samuel <[email protected]>
1 parent b3576d9 commit f82a1eb

File tree

3 files changed

+960
-0
lines changed

3 files changed

+960
-0
lines changed
Lines changed: 307 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,307 @@
1+
# refactored from rest-api-spec/src/main/resources/rest-api-spec/test/search/270_wildcard_fieldtype_queries.yml
2+
---
3+
"search on mixed state":
4+
# "term query matches exact value"
5+
- do:
6+
search:
7+
index: test
8+
body:
9+
query:
10+
term:
11+
my_field: "AbCd"
12+
- match: { hits.total.value: 1 }
13+
- match: { hits.hits.0._id: "5" }
14+
15+
- do:
16+
search:
17+
index: test
18+
body:
19+
query:
20+
term:
21+
my_field.doc_values: "AbCd"
22+
- match: { hits.total.value: 1 }
23+
- match: { hits.hits.0._id: "5" }
24+
25+
# term query matches lowercase-normalized value
26+
- do:
27+
search:
28+
index: test
29+
body:
30+
query:
31+
term:
32+
my_field.lower: "abcd"
33+
- match: { hits.total.value: 2 }
34+
- match: { hits.hits.0._id: "5" }
35+
- match: { hits.hits.1._id: "7" }
36+
37+
- do:
38+
search:
39+
index: test
40+
body:
41+
query:
42+
term:
43+
my_field.lower: "ABCD"
44+
- match: { hits.total.value: 2 }
45+
- match: { hits.hits.0._id: "5" }
46+
- match: { hits.hits.1._id: "7" }
47+
48+
- do:
49+
search:
50+
index: test
51+
body:
52+
query:
53+
term:
54+
my_field: "abcd"
55+
- match: { hits.total.value: 0 }
56+
57+
# wildcard query matches
58+
- do:
59+
search:
60+
index: test
61+
body:
62+
query:
63+
wildcard:
64+
my_field:
65+
value: "*Node*Exception*"
66+
- match: { hits.total.value: 1 }
67+
- match: { hits.hits.0._id: "1" }
68+
69+
# wildcard query matches lowercase-normalized field
70+
- do:
71+
search:
72+
index: test
73+
body:
74+
query:
75+
wildcard:
76+
my_field.lower:
77+
value: "*node*exception*"
78+
- match: { hits.total.value: 1 }
79+
- match: { hits.hits.0._id: "1" }
80+
81+
- do:
82+
search:
83+
index: test
84+
body:
85+
query:
86+
wildcard:
87+
my_field.lower:
88+
value: "*NODE*EXCEPTION*"
89+
- match: { hits.total.value: 1 }
90+
- match: { hits.hits.0._id: "1" }
91+
92+
- do:
93+
search:
94+
index: test
95+
body:
96+
query:
97+
wildcard:
98+
my_field:
99+
value: "*node*exception*"
100+
- match: { hits.total.value: 0 }
101+
102+
# prefix query matches
103+
- do:
104+
search:
105+
index: test
106+
body:
107+
query:
108+
prefix:
109+
my_field:
110+
value: "[2024-06-08T"
111+
- match: { hits.total.value: 3 }
112+
113+
# regexp query matches
114+
- do:
115+
search:
116+
index: test
117+
body:
118+
query:
119+
regexp:
120+
my_field:
121+
value: ".*06-08.*cluster-manager node.*"
122+
- match: { hits.total.value: 2 }
123+
124+
# regexp query matches lowercase-normalized field
125+
- do:
126+
search:
127+
index: test
128+
body:
129+
query:
130+
regexp:
131+
my_field.lower:
132+
value: ".*06-08.*Cluster-Manager Node.*"
133+
- match: { hits.total.value: 2 }
134+
135+
- do:
136+
search:
137+
index: test
138+
body:
139+
query:
140+
regexp:
141+
my_field:
142+
value: ".*06-08.*Cluster-Manager Node.*"
143+
- match: { hits.total.value: 0 }
144+
145+
# wildcard match-all works
146+
- do:
147+
search:
148+
index: test
149+
body:
150+
query:
151+
wildcard:
152+
my_field:
153+
value: "*"
154+
- match: { hits.total.value: 8 }
155+
156+
# regexp match-all works
157+
- do:
158+
search:
159+
index: test
160+
body:
161+
query:
162+
regexp:
163+
my_field:
164+
value: ".*"
165+
- match: { hits.total.value: 8 }
166+
167+
# terms query on wildcard field matches
168+
- do:
169+
search:
170+
index: test
171+
body:
172+
query:
173+
terms: { my_field: [ "AbCd" ] }
174+
- match: { hits.total.value: 1 }
175+
- match: { hits.hits.0._id: "5" }
176+
177+
# case insensitive query on wildcard field
178+
- do:
179+
search:
180+
index: test
181+
body:
182+
query:
183+
wildcard:
184+
my_field:
185+
value: "AbCd"
186+
- match: { hits.total.value: 1 }
187+
- match: { hits.hits.0._id: "5" }
188+
189+
- do:
190+
search:
191+
index: test
192+
body:
193+
query:
194+
wildcard:
195+
my_field:
196+
value: "AbCd"
197+
case_insensitive: true
198+
- match: { hits.total.value: 2 }
199+
- match: { hits.hits.0._id: "5" }
200+
- match: { hits.hits.1._id: "7" }
201+
202+
# case insensitive regexp query on wildcard field
203+
- do:
204+
search:
205+
index: test
206+
body:
207+
query:
208+
regexp:
209+
my_field:
210+
value: "AbCd"
211+
- match: { hits.total.value: 1 }
212+
- match: { hits.hits.0._id: "5" }
213+
- do:
214+
search:
215+
index: test
216+
body:
217+
query:
218+
regexp:
219+
my_field:
220+
value: "AbCd"
221+
case_insensitive: true
222+
- match: { hits.total.value: 2 }
223+
- match: { hits.hits.0._id: "5" }
224+
- match: { hits.hits.1._id: "7" }
225+
226+
# wildcard query works on values contains escaped characters
227+
- do:
228+
search:
229+
index: test
230+
body:
231+
query:
232+
wildcard:
233+
my_field:
234+
value: "\\*"
235+
- match: { hits.total.value: 1 }
236+
- match: { hits.hits.0._id: "8" }
237+
238+
- do:
239+
search:
240+
index: test
241+
body:
242+
query:
243+
wildcard:
244+
my_field:
245+
value: "\\\\\\*"
246+
- match: { hits.total.value: 1 }
247+
- match: { hits.hits.0._id: "9" }
248+
249+
# regexp query works on values contains escaped characters
250+
- do:
251+
search:
252+
index: test
253+
body:
254+
query:
255+
regexp:
256+
my_field:
257+
value: "\\*"
258+
- match: { hits.total.value: 1 }
259+
- match: { hits.hits.0._id: "8" }
260+
- do:
261+
search:
262+
index: test
263+
body:
264+
query:
265+
regexp:
266+
my_field:
267+
value: "\\\\\\*"
268+
- match: { hits.total.value: 1 }
269+
- match: { hits.hits.0._id: "9" }
270+
271+
# term query contains escaped characters
272+
- do:
273+
search:
274+
index: test
275+
body:
276+
query:
277+
term:
278+
my_field: "\\*"
279+
- match: { hits.total.value: 1 }
280+
- match: { hits.hits.0._id: "9" }
281+
- do:
282+
search:
283+
index: test
284+
body:
285+
query:
286+
term:
287+
my_field: "*"
288+
- match: { hits.total.value: 1 }
289+
- match: { hits.hits.0._id: "8"}
290+
291+
# terms query contains escaped characters
292+
- do:
293+
search:
294+
index: test
295+
body:
296+
query:
297+
terms: { my_field: ["*"] }
298+
- match: { hits.total.value: 1 }
299+
- match: { hits.hits.0._id: "8" }
300+
- do:
301+
search:
302+
index: test
303+
body:
304+
query:
305+
terms: { my_field: [ "\\*" ] }
306+
- match: { hits.total.value: 1 }
307+
- match: { hits.hits.0._id: "9" }

0 commit comments

Comments
 (0)