Skip to content

Commit 397a7c0

Browse files
author
Christoph Büscher
committed
Add yaml for search, ranges and scripting
1 parent 343310c commit 397a7c0

File tree

2 files changed

+152
-0
lines changed

2 files changed

+152
-0
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Integration tests for the version field
2+
#
3+
---
4+
setup:
5+
6+
- do:
7+
indices.create:
8+
index: test_index
9+
body:
10+
mappings:
11+
properties:
12+
version:
13+
type: version
14+
15+
- do:
16+
bulk:
17+
refresh: true
18+
body:
19+
- '{ "index" : { "_index" : "test_index", "_id" : "1" } }'
20+
- '{"version": "1.1.0" }'
21+
- '{ "index" : { "_index" : "test_index", "_id" : "2" } }'
22+
- '{"version": "2.0.0-beta" }'
23+
- '{ "index" : { "_index" : "test_index", "_id" : "3" } }'
24+
- '{"version": "3.1.0" }'
25+
26+
---
27+
"Store malformed":
28+
- do:
29+
indices.create:
30+
index: test_malformed
31+
body:
32+
mappings:
33+
properties:
34+
version:
35+
type: version
36+
store_malformed: true
37+
38+
- do:
39+
bulk:
40+
refresh: true
41+
body:
42+
- '{ "index" : { "_index" : "test_malformed", "_id" : "1" } }'
43+
- '{"version": "1.1.0" }'
44+
- '{ "index" : { "_index" : "test_malformed", "_id" : "2" } }'
45+
- '{"version": "2.0.0-beta" }'
46+
- '{ "index" : { "_index" : "test_malformed", "_id" : "3" } }'
47+
- '{"version": "3.1.0" }'
48+
- '{ "index" : { "_index" : "test_malformed", "_id" : "4" } }'
49+
- '{"version": "1.el6" }'
50+
51+
- do:
52+
search:
53+
index: test_malformed
54+
body:
55+
query: { "match" : { "version" : "1.el6" } }
56+
57+
- do:
58+
search:
59+
index: test_malformed
60+
body:
61+
query: { "match_all" : { } }
62+
sort:
63+
version: asc
64+
65+
- match: { hits.total.value: 4 }
66+
- match: { hits.hits.0._source.version: "1.1.0" }
67+
- match: { hits.hits.1._source.version: "2.0.0-beta" }
68+
- match: { hits.hits.2._source.version: "3.1.0" }
69+
- match: { hits.hits.3._source.version: "1.el6" }
70+
71+
---
72+
"Basic ranges":
73+
- do:
74+
search:
75+
index: test_index
76+
body:
77+
query: { "range" : { "version" : { "gt" : "1.1.0", "lt" : "9999" } } }
78+
79+
- match: { hits.total.value: 2 }
80+
81+
- do:
82+
search:
83+
index: test_index
84+
body:
85+
query: { "range" : { "version" : { "gte" : "1.1.0", "lt" : "9999" } } }
86+
87+
- match: { hits.total.value: 3 }
88+
89+
- do:
90+
search:
91+
index: test_index
92+
body:
93+
query: { "range" : { "version" : { "gte" : "2.0.0", "lt" : "9999" } } }
94+
95+
- match: { hits.total.value: 1 }
96+
97+
- do:
98+
search:
99+
index: test_index
100+
body:
101+
query: { "range" : { "version" : { "gte" : "2.0.0-alpha", "lt" : "9999" } } }
102+
103+
- match: { hits.total.value: 2 }
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Integration tests for the version field
2+
#
3+
---
4+
setup:
5+
6+
- do:
7+
indices.create:
8+
index: test_index
9+
body:
10+
mappings:
11+
properties:
12+
version:
13+
type: version
14+
15+
- do:
16+
bulk:
17+
refresh: true
18+
body:
19+
- '{ "index" : { "_index" : "test_index", "_id" : "1" } }'
20+
- '{"version": "1.1.12" }'
21+
- '{ "index" : { "_index" : "test_index", "_id" : "2" } }'
22+
- '{"version": "2.0.0-beta" }'
23+
- '{ "index" : { "_index" : "test_index", "_id" : "3" } }'
24+
- '{"version": "3.1.0" }'
25+
26+
---
27+
"Filter script":
28+
- do:
29+
search:
30+
index: test_index
31+
body:
32+
query: { "script" : { "script" : { "source": "doc['version'].value.length() > 5"} } }
33+
34+
- match: { hits.total.value: 2 }
35+
- match: { hits.hits.0._source.version: "1.1.12" }
36+
- match: { hits.hits.1._source.version: "2.0.0-beta" }
37+
38+
---
39+
"Sort script":
40+
- do:
41+
search:
42+
index: test_index
43+
body:
44+
sort: { "_script" : { "type" : "number", "script" : { "source": "doc['version'].value.length()" } } }
45+
46+
- match: { hits.total.value: 3 }
47+
- match: { hits.hits.0._source.version: "3.1.0" }
48+
- match: { hits.hits.1._source.version: "1.1.12" }
49+
- match: { hits.hits.2._source.version: "2.0.0-beta" }

0 commit comments

Comments
 (0)