forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20_search.yml
195 lines (182 loc) · 4.78 KB
/
20_search.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Integration tests for phone analysis components
#
---
"Index phone number content":
- do:
indices.create:
index: test
body:
settings:
index:
analysis:
analyzer:
phone-ch:
type: "phone"
"phone-region": "CH"
phone-search-ch:
type: "phone-search"
"phone-region": "CH"
mappings:
properties:
phone:
type: text
analyzer: "phone"
search_analyzer: "phone-search"
phone-ch:
type: text
analyzer: "phone-ch"
search_analyzer: "phone-search-ch"
- do:
index:
index: test
id: 1
body: { "phone": "+41 58 316 10 10", "phone-ch": "058 316 10 10" }
- do:
index:
index: test
id: 2
body: { "phone": "+41 58 316 99 99", "phone-ch": "058 316 99 99" }
- do:
index:
index: test
id: 3
# number not used in the examples below, just present to make sure that it's never matched
body: { "phone": "+41 12 345 67 89", "phone-ch": "012 345 67 89" }
- do:
index:
index: test
id: 4
# germany has a different phone number length, but for this test we ignore it and pretend they're the same
body: { "phone": "+49 58 316 10 10", "phone-ch": "+49 58 316 10 10" }
- do:
index:
index: test
id: 5
body: { "phone": "+1-888-280-4331", "phone-ch": "+1-888-280-4331" }
- do:
index:
index: test
id: 6
body: { "phone": "tel:+441344840400", "phone-ch": "tel:+441344840400" }
- do:
indices.refresh: {}
# international format in document & search will always work
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "+41583161010"
- match: { hits.total: 1 }
# correct national format & international format in search will always work
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone-ch": "+41583161010"
- match: { hits.total: 1 }
# national format without country specified won't work
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "0583161010"
- match: { hits.total: 0 }
# correct national format with country specified in document & search will always work
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone-ch": "0583161010"
- match: { hits.total: 1 }
# search-as-you-type style query
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "+4158316"
- match: { hits.total: 2 }
# search-as-you-type style query
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone-ch": "058316"
- match: { hits.total: 2 }
# international format in document & search will always work
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "+1 888 280 4331"
- match: { hits.total: 1 }
# international format in document & search will always work
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone-ch": "+1 888 280 4331"
- match: { hits.total: 1 }
# national format in search won't work if no country is specified
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "888 280 4331"
- match: { hits.total: 0 }
# document & search have a tel: prefix
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "tel:+441344840400"
- match: { hits.total: 1 }
# only document has a tel: prefix
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "+441344840400"
- match: { hits.total: 1 }
# only search has a tel: prefix
- do:
search:
rest_total_hits_as_int: true
index: test
body:
query:
match:
"phone": "tel:+1 888 280 4331"
- match: { hits.total: 1 }