Skip to content

Commit 40e205e

Browse files
committed
Added integration tests for match_only_text replicating text field integ tests
Signed-off-by: Rishabh Maurya <rishabhmaurya05@gmail.com>
1 parent b765a36 commit 40e205e

19 files changed

Lines changed: 2684 additions & 0 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# integration tests for queries with specific analysis chains
2+
3+
"match query with stacked stems":
4+
# Tests the match query stemmed tokens are "stacked" on top of the unstemmed
5+
# versions in the same position.
6+
- do:
7+
indices.create:
8+
index: test
9+
body:
10+
settings:
11+
number_of_shards: 1
12+
number_of_replicas: 1
13+
analysis:
14+
analyzer:
15+
index:
16+
tokenizer: standard
17+
filter: [lowercase]
18+
search:
19+
rest_total_hits_as_int: true
20+
tokenizer: standard
21+
filter: [lowercase, keyword_repeat, porter_stem, unique_stem]
22+
filter:
23+
unique_stem:
24+
type: unique
25+
only_on_same_position: true
26+
mappings:
27+
properties:
28+
text:
29+
type: match_only_text
30+
analyzer: index
31+
search_analyzer: search
32+
33+
- do:
34+
index:
35+
index: test
36+
id: 1
37+
body: { "text": "the fox runs across the street" }
38+
refresh: true
39+
40+
- do:
41+
search:
42+
rest_total_hits_as_int: true
43+
body:
44+
query:
45+
match:
46+
text:
47+
query: fox runs
48+
operator: AND
49+
- match: {hits.total: 1}
50+
51+
- do:
52+
index:
53+
index: test
54+
id: 2
55+
body: { "text": "run fox run" }
56+
refresh: true
57+
58+
- do:
59+
search:
60+
rest_total_hits_as_int: true
61+
body:
62+
query:
63+
match:
64+
text:
65+
query: fox runs
66+
operator: AND
67+
- match: {hits.total: 2}
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
"ngram search":
2+
- do:
3+
indices.create:
4+
index: test
5+
body:
6+
settings:
7+
number_of_shards: 1
8+
number_of_replicas: 0
9+
analysis:
10+
analyzer:
11+
my_analyzer:
12+
tokenizer: standard
13+
filter: [my_ngram]
14+
filter:
15+
my_ngram:
16+
type: ngram
17+
min: 2,
18+
max: 2
19+
mappings:
20+
properties:
21+
text:
22+
type: match_only_text
23+
analyzer: my_analyzer
24+
25+
- do:
26+
index:
27+
index: test
28+
id: 1
29+
body: { "text": "foo bar baz" }
30+
refresh: true
31+
32+
- do:
33+
search:
34+
rest_total_hits_as_int: true
35+
body:
36+
query:
37+
match:
38+
text:
39+
query: foa
40+
- match: {hits.total: 1}
41+
42+
---
43+
"testNGramCopyField":
44+
- do:
45+
indices.create:
46+
index: test
47+
body:
48+
settings:
49+
number_of_shards: 1
50+
number_of_replicas: 0
51+
max_ngram_diff: 9
52+
analysis:
53+
analyzer:
54+
my_ngram_analyzer:
55+
tokenizer: my_ngram_tokenizer
56+
tokenizer:
57+
my_ngram_tokenizer:
58+
type: ngram
59+
min: 1,
60+
max: 10
61+
token_chars: []
62+
mappings:
63+
properties:
64+
origin:
65+
type: match_only_text
66+
copy_to: meta
67+
meta:
68+
type: match_only_text
69+
analyzer: my_ngram_analyzer
70+
71+
- do:
72+
index:
73+
index: test
74+
id: 1
75+
body: { "origin": "C.A1234.5678" }
76+
refresh: true
77+
78+
- do:
79+
search:
80+
rest_total_hits_as_int: true
81+
body:
82+
query:
83+
match:
84+
meta:
85+
query: 1234
86+
- match: {hits.total: 1}
87+
88+
- do:
89+
search:
90+
rest_total_hits_as_int: true
91+
body:
92+
query:
93+
match:
94+
meta:
95+
query: 1234.56
96+
- match: {hits.total: 1}
97+
98+
- do:
99+
search:
100+
rest_total_hits_as_int: true
101+
body:
102+
query:
103+
match:
104+
meta:
105+
query: A1234
106+
- match: {hits.total: 1}
107+
108+
- do:
109+
search:
110+
rest_total_hits_as_int: true
111+
body:
112+
query:
113+
term:
114+
meta:
115+
value: a1234
116+
- match: {hits.total: 0}
117+
118+
- do:
119+
search:
120+
rest_total_hits_as_int: true
121+
body:
122+
query:
123+
match:
124+
meta:
125+
query: A1234
126+
analyzer: my_ngram_analyzer
127+
- match: {hits.total: 1}
128+
129+
- do:
130+
search:
131+
rest_total_hits_as_int: true
132+
body:
133+
query:
134+
match:
135+
meta:
136+
query: a1234
137+
analyzer: my_ngram_analyzer
138+
- match: {hits.total: 1}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
"ngram highlighting":
2+
- do:
3+
indices.create:
4+
index: test
5+
body:
6+
settings:
7+
number_of_shards: 1
8+
number_of_replicas: 0
9+
index.max_ngram_diff: 19
10+
analysis:
11+
tokenizer:
12+
my_ngramt:
13+
type: ngram
14+
min_gram: 1
15+
max_gram: 20
16+
token_chars: letter,digit
17+
filter:
18+
my_ngram:
19+
type: ngram
20+
min_gram: 1
21+
max_gram: 20
22+
analyzer:
23+
name2_index_analyzer:
24+
tokenizer: whitespace
25+
filter: [my_ngram]
26+
name_index_analyzer:
27+
tokenizer: my_ngramt
28+
name_search_analyzer:
29+
tokenizer: whitespace
30+
mappings:
31+
properties:
32+
name:
33+
type: match_only_text
34+
term_vector: with_positions_offsets
35+
analyzer: name_index_analyzer
36+
search_analyzer: name_search_analyzer
37+
name2:
38+
type: match_only_text
39+
term_vector: with_positions_offsets
40+
analyzer: name2_index_analyzer
41+
search_analyzer: name_search_analyzer
42+
43+
- do:
44+
index:
45+
index: test
46+
id: 1
47+
refresh: true
48+
body:
49+
name: logicacmg ehemals avinci - the know how company
50+
name2: logicacmg ehemals avinci - the know how company
51+
52+
- do:
53+
search:
54+
rest_total_hits_as_int: true
55+
body:
56+
query:
57+
match:
58+
name:
59+
query: logica m
60+
highlight:
61+
fields:
62+
- name: {}
63+
- match: {hits.total: 1}
64+
- match: {hits.hits.0.highlight.name.0: "<em>logica</em>c<em>m</em>g ehe<em>m</em>als avinci - the know how co<em>m</em>pany"}
65+
66+
- do:
67+
search:
68+
rest_total_hits_as_int: true
69+
body:
70+
query:
71+
match:
72+
name:
73+
query: logica ma
74+
highlight:
75+
fields:
76+
- name: {}
77+
- match: {hits.total: 1}
78+
- match: {hits.hits.0.highlight.name.0: "<em>logica</em>cmg ehe<em>ma</em>ls avinci - the know how company"}
79+
80+
- do:
81+
search:
82+
rest_total_hits_as_int: true
83+
body:
84+
query:
85+
match:
86+
name:
87+
query: logica
88+
highlight:
89+
fields:
90+
- name: {}
91+
- match: {hits.total: 1}
92+
- match: {hits.hits.0.highlight.name.0: "<em>logica</em>cmg ehemals avinci - the know how company"}
93+
94+
- do:
95+
search:
96+
rest_total_hits_as_int: true
97+
body:
98+
query:
99+
match:
100+
name2:
101+
query: logica m
102+
highlight:
103+
fields:
104+
- name2: {}
105+
- match: {hits.total: 1}
106+
- match: {hits.hits.0.highlight.name2.0: "<em>logicacmg</em> <em>ehemals</em> avinci - the know how <em>company</em>"}
107+
108+
- do:
109+
search:
110+
rest_total_hits_as_int: true
111+
body:
112+
query:
113+
match:
114+
name2:
115+
query: logica ma
116+
highlight:
117+
fields:
118+
- name2: {}
119+
- match: {hits.total: 1}
120+
- match: {hits.hits.0.highlight.name2.0: "<em>logicacmg</em> <em>ehemals</em> avinci - the know how company"}
121+
122+
- do:
123+
search:
124+
rest_total_hits_as_int: true
125+
body:
126+
query:
127+
match:
128+
name2:
129+
query: logica
130+
highlight:
131+
fields:
132+
- name2: {}
133+
- match: {hits.total: 1}
134+
- match: {hits.hits.0.highlight.name2.0: "<em>logicacmg</em> ehemals avinci - the know how company"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
"Test query string with snowball":
3+
- do:
4+
indices.create:
5+
index: test
6+
body:
7+
mappings:
8+
properties:
9+
field:
10+
type: match_only_text
11+
number:
12+
type: integer
13+
14+
- do:
15+
index:
16+
index: test
17+
id: 1
18+
body: { field: foo bar}
19+
20+
- do:
21+
indices.refresh:
22+
index: [test]
23+
24+
- do:
25+
indices.validate_query:
26+
index: test
27+
q: field:bars
28+
analyzer: snowball
29+
30+
- is_true: valid
31+
32+
- do:
33+
search:
34+
rest_total_hits_as_int: true
35+
index: test
36+
q: field:bars
37+
analyzer: snowball
38+
39+
- match: {hits.total: 1}
40+
41+
- do:
42+
explain:
43+
index: test
44+
id: 1
45+
q: field:bars
46+
analyzer: snowball
47+
48+
- is_true: matched
49+
50+
- do:
51+
count:
52+
index: test
53+
q: field:bars
54+
analyzer: snowball
55+
56+
- match: {count : 1}

0 commit comments

Comments
 (0)