Skip to content

Commit 67e003d

Browse files
authored
Add REST tests for value_count, stats, extended_stats and cardinality aggs (#26239)
* Add REST tests for value_count, stats, extended_stats and cardinality aggs Also updates the document type of of other agg REST tests to `doc` Related to #26220
1 parent e3cc246 commit 67e003d

File tree

8 files changed

+901
-20
lines changed

8 files changed

+901
-20
lines changed

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/100_avg_metric.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ setup:
66
settings:
77
number_of_replicas: 0
88
mappings:
9-
test:
9+
doc:
1010
properties:
1111
int_field:
1212
type : integer
@@ -21,28 +21,28 @@ setup:
2121
body:
2222
- index:
2323
_index: test_1
24-
_type: test
24+
_type: doc
2525
_id: 1
2626
- int_field: 1
2727
double_field: 1.0
2828
string_field: foo
2929
- index:
3030
_index: test_1
31-
_type: test
31+
_type: doc
3232
_id: 2
3333
- int_field: 51
3434
double_field: 51.0
3535
string_field: foo
3636
- index:
3737
_index: test_1
38-
_type: test
38+
_type: doc
3939
_id: 3
4040
- int_field: 101
4141
double_field: 101.0
4242
string_field: foo
4343
- index:
4444
_index: test_1
45-
_type: test
45+
_type: doc
4646
_id: 4
4747
- int_field: 151
4848
double_field: 151.0

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/110_max_metric.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,48 @@ setup:
66
settings:
77
number_of_replicas: 0
88
mappings:
9-
test:
9+
doc:
1010
properties:
1111
int_field:
1212
type : integer
1313
double_field:
1414
type : double
1515
string_field:
1616
type: keyword
17+
1718
- do:
1819
bulk:
1920
refresh: true
2021
body:
2122
- index:
2223
_index: test_1
23-
_type: test
24+
_type: doc
2425
_id: 1
2526
- int_field: 1
2627
double_field: 1.0
2728
string_field: foo
2829
- index:
2930
_index: test_1
30-
_type: test
31+
_type: doc
3132
_id: 2
3233
- int_field: 51
3334
double_field: 51.0
3435
string_field: foo
3536
- index:
3637
_index: test_1
37-
_type: test
38+
_type: doc
3839
_id: 3
3940
- int_field: 101
4041
double_field: 101.0
4142
string_field: foo
4243
- index:
4344
_index: test_1
44-
_type: test
45+
_type: doc
4546
_id: 4
4647
- int_field: 151
4748
double_field: 151.0
4849
string_field: foo
50+
4951
---
5052
"Basic test":
5153

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/120_min_metric.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,48 @@ setup:
66
settings:
77
number_of_replicas: 0
88
mappings:
9-
test:
9+
doc:
1010
properties:
1111
int_field:
1212
type : integer
1313
double_field:
1414
type : double
1515
string_field:
1616
type: keyword
17+
1718
- do:
1819
bulk:
1920
refresh: true
2021
body:
2122
- index:
2223
_index: test_1
23-
_type: test
24+
_type: doc
2425
_id: 1
2526
- int_field: 1
2627
double_field: 1.0
2728
string_field: foo
2829
- index:
2930
_index: test_1
30-
_type: test
31+
_type: doc
3132
_id: 2
3233
- int_field: 51
3334
double_field: 51.0
3435
string_field: foo
3536
- index:
3637
_index: test_1
37-
_type: test
38+
_type: doc
3839
_id: 3
3940
- int_field: 101
4041
double_field: 101.0
4142
string_field: foo
4243
- index:
4344
_index: test_1
44-
_type: test
45+
_type: doc
4546
_id: 4
4647
- int_field: 151
4748
double_field: 151.0
4849
string_field: foo
50+
4951
---
5052
"Basic test":
5153

rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/130_sum_metric.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,48 @@ setup:
66
settings:
77
number_of_replicas: 0
88
mappings:
9-
test:
9+
doc:
1010
properties:
1111
int_field:
1212
type : integer
1313
double_field:
1414
type : double
1515
string_field:
1616
type: keyword
17+
1718
- do:
1819
bulk:
1920
refresh: true
2021
body:
2122
- index:
2223
_index: test_1
23-
_type: test
24+
_type: doc
2425
_id: 1
2526
- int_field: 1
2627
double_field: 1.0
2728
string_field: foo
2829
- index:
2930
_index: test_1
30-
_type: test
31+
_type: doc
3132
_id: 2
3233
- int_field: 51
3334
double_field: 51.0
3435
string_field: foo
3536
- index:
3637
_index: test_1
37-
_type: test
38+
_type: doc
3839
_id: 3
3940
- int_field: 101
4041
double_field: 101.0
4142
string_field: foo
4243
- index:
4344
_index: test_1
44-
_type: test
45+
_type: doc
4546
_id: 4
4647
- int_field: 151
4748
double_field: 151.0
4849
string_field: foo
50+
4951
---
5052
"Basic test":
5153

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: test_1
5+
body:
6+
settings:
7+
number_of_replicas: 0
8+
mappings:
9+
doc:
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: doc
25+
_id: 1
26+
- int_field: 1
27+
double_field: 1.0
28+
string_field: foo
29+
- index:
30+
_index: test_1
31+
_type: doc
32+
_id: 2
33+
- int_field: 51
34+
double_field: 51.0
35+
string_field: foo
36+
- index:
37+
_index: test_1
38+
_type: doc
39+
_id: 3
40+
- int_field: 101
41+
double_field: 101.0
42+
string_field: foo
43+
- index:
44+
_index: test_1
45+
_type: doc
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_value_count:
59+
value_count:
60+
field: int_field
61+
the_double_value_count:
62+
value_count:
63+
field: double_field
64+
the_string_value_count:
65+
value_count:
66+
field: string_field
67+
68+
- match: { hits.total: 4 }
69+
- length: { hits.hits: 4 }
70+
- match: { aggregations.the_int_value_count.value: 4 }
71+
- match: { aggregations.the_double_value_count.value: 4 }
72+
- match: { aggregations.the_string_value_count.value: 4 }
73+
74+
---
75+
"Only aggs test":
76+
77+
- do:
78+
search:
79+
body:
80+
size: 0
81+
aggs:
82+
the_int_value_count:
83+
value_count:
84+
field: int_field
85+
the_double_value_count:
86+
value_count:
87+
field: double_field
88+
the_string_value_count:
89+
value_count:
90+
field: string_field
91+
92+
- match: { hits.total: 4 }
93+
- length: { hits.hits: 0 }
94+
- match: { aggregations.the_int_value_count.value: 4 }
95+
- match: { aggregations.the_double_value_count.value: 4 }
96+
- match: { aggregations.the_string_value_count.value: 4 }
97+
98+
---
99+
"Filtered test":
100+
101+
- do:
102+
search:
103+
body:
104+
query:
105+
constant_score:
106+
filter:
107+
range:
108+
int_field:
109+
gte: 50
110+
aggs:
111+
the_int_value_count:
112+
value_count:
113+
field: int_field
114+
the_double_value_count:
115+
value_count:
116+
field: double_field
117+
the_string_value_count:
118+
value_count:
119+
field: string_field
120+
121+
- match: { hits.total: 3 }
122+
- length: { hits.hits: 3 }
123+
- match: { aggregations.the_int_value_count.value: 3 }
124+
- match: { aggregations.the_double_value_count.value: 3 }
125+
- match: { aggregations.the_string_value_count.value: 3 }
126+
127+
128+
---
129+
"Missing field with missing param":
130+
131+
- do:
132+
search:
133+
body:
134+
aggs:
135+
the_missing_value_count:
136+
value_count:
137+
field: foo
138+
missing: 1
139+
140+
- match: { hits.total: 4 }
141+
- length: { hits.hits: 4 }
142+
- match: { aggregations.the_missing_value_count.value: 4 }
143+
144+
---
145+
"Missing field without missing param":
146+
147+
- do:
148+
search:
149+
body:
150+
aggs:
151+
the_missing_value_count:
152+
value_count:
153+
field: foo
154+
155+
- match: { hits.total: 4 }
156+
- length: { hits.hits: 4 }
157+
- is_false: aggregations.the_missing_value_count.value
158+
159+
---
160+
"Metadata test":
161+
162+
- do:
163+
search:
164+
body:
165+
aggs:
166+
the_int_value_count:
167+
meta:
168+
foo: bar
169+
value_count:
170+
field: int_field
171+
172+
- match: { hits.total: 4 }
173+
- length: { hits.hits: 4 }
174+
- match: { aggregations.the_int_value_count.value: 4 }
175+
- match: { aggregations.the_int_value_count.meta.foo: "bar" }

0 commit comments

Comments
 (0)