-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add REST tests for avg/min/max/sum metric aggs (#26225)
Adds some REST tests for avg/min/max/sum metric aggregations Related to #26220
- Loading branch information
1 parent
f35754c
commit 9ece56b
Showing
4 changed files
with
697 additions
and
0 deletions.
There are no files selected for viewing
176 changes: 176 additions & 0 deletions
176
rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/100_avg_metric.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test_1 | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
test: | ||
properties: | ||
int_field: | ||
type : integer | ||
double_field: | ||
type : double | ||
string_field: | ||
type: keyword | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 1 | ||
- int_field: 1 | ||
double_field: 1.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 2 | ||
- int_field: 51 | ||
double_field: 51.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 3 | ||
- int_field: 101 | ||
double_field: 101.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 4 | ||
- int_field: 151 | ||
double_field: 151.0 | ||
string_field: foo | ||
|
||
--- | ||
"Basic test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_int_avg: | ||
avg: | ||
field: int_field | ||
the_double_avg: | ||
avg: | ||
field: double_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_int_avg.value: 76.0 } | ||
- match: { aggregations.the_double_avg.value: 76.0 } | ||
|
||
--- | ||
"Only aggs test": | ||
|
||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
the_int_avg: | ||
avg: | ||
field: int_field | ||
the_double_avg: | ||
avg: | ||
field: double_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 0 } | ||
- match: { aggregations.the_int_avg.value: 76.0 } | ||
- match: { aggregations.the_double_avg.value: 76.0 } | ||
|
||
--- | ||
"Filtered test": | ||
|
||
- do: | ||
search: | ||
body: | ||
query: | ||
constant_score: | ||
filter: | ||
range: | ||
int_field: | ||
gte: 50 | ||
aggs: | ||
the_int_avg: | ||
avg: | ||
field: int_field | ||
the_double_avg: | ||
avg: | ||
field: double_field | ||
|
||
- match: { hits.total: 3 } | ||
- length: { hits.hits: 3 } | ||
- match: { aggregations.the_int_avg.value: 101.0 } | ||
- match: { aggregations.the_double_avg.value: 101.0 } | ||
|
||
|
||
--- | ||
"Missing field with missing param": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_missing_avg: | ||
avg: | ||
field: foo | ||
missing: 1 | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_missing_avg.value: 1 } | ||
|
||
--- | ||
"Missing field without missing param": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_missing_avg: | ||
avg: | ||
field: foo | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- is_false: aggregations.the_missing_avg.value | ||
|
||
--- | ||
"Metadata test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_int_avg: | ||
meta: | ||
foo: bar | ||
avg: | ||
field: int_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_int_avg.value: 76.0 } | ||
- match: { aggregations.the_int_avg.meta.foo: "bar" } | ||
|
||
--- | ||
"Aggregating wrong datatype test": | ||
|
||
- do: | ||
catch: request | ||
search: | ||
body: | ||
aggs: | ||
the_string_avg: | ||
avg: | ||
field: string_field | ||
|
173 changes: 173 additions & 0 deletions
173
rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/110_max_metric.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test_1 | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
test: | ||
properties: | ||
int_field: | ||
type : integer | ||
double_field: | ||
type : double | ||
string_field: | ||
type: keyword | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 1 | ||
- int_field: 1 | ||
double_field: 1.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 2 | ||
- int_field: 51 | ||
double_field: 51.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 3 | ||
- int_field: 101 | ||
double_field: 101.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: test | ||
_id: 4 | ||
- int_field: 151 | ||
double_field: 151.0 | ||
string_field: foo | ||
--- | ||
"Basic test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_int_max: | ||
max: | ||
field: int_field | ||
the_double_max: | ||
max: | ||
field: double_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_int_max.value: 151.0 } | ||
- match: { aggregations.the_double_max.value: 151.0 } | ||
|
||
--- | ||
"Only aggs test": | ||
|
||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
the_int_max: | ||
max: | ||
field: int_field | ||
the_double_max: | ||
max: | ||
field: double_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 0 } | ||
- match: { aggregations.the_int_max.value: 151.0 } | ||
- match: { aggregations.the_double_max.value: 151.0 } | ||
|
||
--- | ||
"Filtered test": | ||
|
||
- do: | ||
search: | ||
body: | ||
query: | ||
constant_score: | ||
filter: | ||
range: | ||
int_field: | ||
lte: 60 | ||
aggs: | ||
the_int_max: | ||
max: | ||
field: int_field | ||
the_double_max: | ||
max: | ||
field: double_field | ||
|
||
- match: { hits.total: 2 } | ||
- length: { hits.hits: 2 } | ||
- match: { aggregations.the_int_max.value: 51.0 } | ||
- match: { aggregations.the_double_max.value: 51.0 } | ||
|
||
|
||
--- | ||
"Missing field with missing param": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_missing_max: | ||
max: | ||
field: foo | ||
missing: 1 | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_missing_max.value: 1 } | ||
|
||
--- | ||
"Missing field without missing param": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_missing_max: | ||
max: | ||
field: foo | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- is_false: aggregations.the_missing_max.value | ||
|
||
--- | ||
"Metadata test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
the_int_max: | ||
meta: | ||
foo: bar | ||
max: | ||
field: int_field | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.the_int_max.value: 151.0 } | ||
- match: { aggregations.the_int_max.meta.foo: "bar" } | ||
|
||
--- | ||
"Aggregating wrong datatype test": | ||
|
||
- do: | ||
catch: request | ||
search: | ||
body: | ||
aggs: | ||
the_string_avg: | ||
avg: | ||
field: string_field |
Oops, something went wrong.