File tree Expand file tree Collapse file tree 4 files changed +697
-0
lines changed
rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation Expand file tree Collapse file tree 4 files changed +697
-0
lines changed Original file line number Diff line number Diff line change 1+ setup :
2+ - do :
3+ indices.create :
4+ index : test_1
5+ body :
6+ settings :
7+ number_of_replicas : 0
8+ mappings :
9+ test :
10+ properties :
11+ int_field :
12+ type : integer
13+ double_field :
14+ type : double
15+ string_field :
16+ type : keyword
17+
18+ - do :
19+ bulk :
20+ refresh : true
21+ body :
22+ - index :
23+ _index : test_1
24+ _type : test
25+ _id : 1
26+ - int_field : 1
27+ double_field : 1.0
28+ string_field : foo
29+ - index :
30+ _index : test_1
31+ _type : test
32+ _id : 2
33+ - int_field : 51
34+ double_field : 51.0
35+ string_field : foo
36+ - index :
37+ _index : test_1
38+ _type : test
39+ _id : 3
40+ - int_field : 101
41+ double_field : 101.0
42+ string_field : foo
43+ - index :
44+ _index : test_1
45+ _type : test
46+ _id : 4
47+ - int_field : 151
48+ double_field : 151.0
49+ string_field : foo
50+
51+ ---
52+ " Basic test " :
53+
54+ - do :
55+ search :
56+ body :
57+ aggs :
58+ the_int_avg :
59+ avg :
60+ field : int_field
61+ the_double_avg :
62+ avg :
63+ field : double_field
64+
65+ - match : { hits.total: 4 }
66+ - length : { hits.hits: 4 }
67+ - match : { aggregations.the_int_avg.value: 76.0 }
68+ - match : { aggregations.the_double_avg.value: 76.0 }
69+
70+ ---
71+ " Only aggs test " :
72+
73+ - do :
74+ search :
75+ body :
76+ size : 0
77+ aggs :
78+ the_int_avg :
79+ avg :
80+ field : int_field
81+ the_double_avg :
82+ avg :
83+ field : double_field
84+
85+ - match : { hits.total: 4 }
86+ - length : { hits.hits: 0 }
87+ - match : { aggregations.the_int_avg.value: 76.0 }
88+ - match : { aggregations.the_double_avg.value: 76.0 }
89+
90+ ---
91+ " Filtered test " :
92+
93+ - do :
94+ search :
95+ body :
96+ query :
97+ constant_score :
98+ filter :
99+ range :
100+ int_field :
101+ gte : 50
102+ aggs :
103+ the_int_avg :
104+ avg :
105+ field : int_field
106+ the_double_avg :
107+ avg :
108+ field : double_field
109+
110+ - match : { hits.total: 3 }
111+ - length : { hits.hits: 3 }
112+ - match : { aggregations.the_int_avg.value: 101.0 }
113+ - match : { aggregations.the_double_avg.value: 101.0 }
114+
115+
116+ ---
117+ " Missing field with missing param " :
118+
119+ - do :
120+ search :
121+ body :
122+ aggs :
123+ the_missing_avg :
124+ avg :
125+ field : foo
126+ missing : 1
127+
128+ - match : { hits.total: 4 }
129+ - length : { hits.hits: 4 }
130+ - match : { aggregations.the_missing_avg.value: 1 }
131+
132+ ---
133+ " Missing field without missing param " :
134+
135+ - do :
136+ search :
137+ body :
138+ aggs :
139+ the_missing_avg :
140+ avg :
141+ field : foo
142+
143+ - match : { hits.total: 4 }
144+ - length : { hits.hits: 4 }
145+ - is_false : aggregations.the_missing_avg.value
146+
147+ ---
148+ " Metadata test " :
149+
150+ - do :
151+ search :
152+ body :
153+ aggs :
154+ the_int_avg :
155+ meta :
156+ foo : bar
157+ avg :
158+ field : int_field
159+
160+ - match : { hits.total: 4 }
161+ - length : { hits.hits: 4 }
162+ - match : { aggregations.the_int_avg.value: 76.0 }
163+ - match : { aggregations.the_int_avg.meta.foo: "bar" }
164+
165+ ---
166+ " Aggregating wrong datatype test " :
167+
168+ - do :
169+ catch : request
170+ search :
171+ body :
172+ aggs :
173+ the_string_avg :
174+ avg :
175+ field : string_field
176+
Original file line number Diff line number Diff line change 1+ setup :
2+ - do :
3+ indices.create :
4+ index : test_1
5+ body :
6+ settings :
7+ number_of_replicas : 0
8+ mappings :
9+ test :
10+ properties :
11+ int_field :
12+ type : integer
13+ double_field :
14+ type : double
15+ string_field :
16+ type : keyword
17+ - do :
18+ bulk :
19+ refresh : true
20+ body :
21+ - index :
22+ _index : test_1
23+ _type : test
24+ _id : 1
25+ - int_field : 1
26+ double_field : 1.0
27+ string_field : foo
28+ - index :
29+ _index : test_1
30+ _type : test
31+ _id : 2
32+ - int_field : 51
33+ double_field : 51.0
34+ string_field : foo
35+ - index :
36+ _index : test_1
37+ _type : test
38+ _id : 3
39+ - int_field : 101
40+ double_field : 101.0
41+ string_field : foo
42+ - index :
43+ _index : test_1
44+ _type : test
45+ _id : 4
46+ - int_field : 151
47+ double_field : 151.0
48+ string_field : foo
49+ ---
50+ " Basic test " :
51+
52+ - do :
53+ search :
54+ body :
55+ aggs :
56+ the_int_max :
57+ max :
58+ field : int_field
59+ the_double_max :
60+ max :
61+ field : double_field
62+
63+ - match : { hits.total: 4 }
64+ - length : { hits.hits: 4 }
65+ - match : { aggregations.the_int_max.value: 151.0 }
66+ - match : { aggregations.the_double_max.value: 151.0 }
67+
68+ ---
69+ " Only aggs test " :
70+
71+ - do :
72+ search :
73+ body :
74+ size : 0
75+ aggs :
76+ the_int_max :
77+ max :
78+ field : int_field
79+ the_double_max :
80+ max :
81+ field : double_field
82+
83+ - match : { hits.total: 4 }
84+ - length : { hits.hits: 0 }
85+ - match : { aggregations.the_int_max.value: 151.0 }
86+ - match : { aggregations.the_double_max.value: 151.0 }
87+
88+ ---
89+ " Filtered test " :
90+
91+ - do :
92+ search :
93+ body :
94+ query :
95+ constant_score :
96+ filter :
97+ range :
98+ int_field :
99+ lte : 60
100+ aggs :
101+ the_int_max :
102+ max :
103+ field : int_field
104+ the_double_max :
105+ max :
106+ field : double_field
107+
108+ - match : { hits.total: 2 }
109+ - length : { hits.hits: 2 }
110+ - match : { aggregations.the_int_max.value: 51.0 }
111+ - match : { aggregations.the_double_max.value: 51.0 }
112+
113+
114+ ---
115+ " Missing field with missing param " :
116+
117+ - do :
118+ search :
119+ body :
120+ aggs :
121+ the_missing_max :
122+ max :
123+ field : foo
124+ missing : 1
125+
126+ - match : { hits.total: 4 }
127+ - length : { hits.hits: 4 }
128+ - match : { aggregations.the_missing_max.value: 1 }
129+
130+ ---
131+ " Missing field without missing param " :
132+
133+ - do :
134+ search :
135+ body :
136+ aggs :
137+ the_missing_max :
138+ max :
139+ field : foo
140+
141+ - match : { hits.total: 4 }
142+ - length : { hits.hits: 4 }
143+ - is_false : aggregations.the_missing_max.value
144+
145+ ---
146+ " Metadata test " :
147+
148+ - do :
149+ search :
150+ body :
151+ aggs :
152+ the_int_max :
153+ meta :
154+ foo : bar
155+ max :
156+ field : int_field
157+
158+ - match : { hits.total: 4 }
159+ - length : { hits.hits: 4 }
160+ - match : { aggregations.the_int_max.value: 151.0 }
161+ - match : { aggregations.the_int_max.meta.foo: "bar" }
162+
163+ ---
164+ " Aggregating wrong datatype test " :
165+
166+ - do :
167+ catch : request
168+ search :
169+ body :
170+ aggs :
171+ the_string_avg :
172+ avg :
173+ field : string_field
You can’t perform that action at this time.
0 commit comments