forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add YAML REST tests for percentile_ranks
Related to elastic#26220
- Loading branch information
1 parent
cfa4646
commit bb143ef
Showing
2 changed files
with
587 additions
and
0 deletions.
There are no files selected for viewing
264 changes: 264 additions & 0 deletions
264
...n/resources/rest-api-spec/test/search.aggregation/200_percentile_ranks_tdigest_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,264 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test_1 | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
doc: | ||
properties: | ||
int_field: | ||
type : integer | ||
double_field: | ||
type : double | ||
string_field: | ||
type: keyword | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 1 | ||
- int_field: 1 | ||
double_field: 1.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 2 | ||
- int_field: 51 | ||
double_field: 51.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 3 | ||
- int_field: 101 | ||
double_field: 101.0 | ||
string_field: foo | ||
- index: | ||
_index: test_1 | ||
_type: doc | ||
_id: 4 | ||
- int_field: 151 | ||
double_field: 151.0 | ||
string_field: foo | ||
|
||
--- | ||
"Basic test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: [50, 99] | ||
percentile_ranks_double: | ||
percentile_ranks: | ||
field: double_field | ||
values: [50, 99] | ||
|
||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: | ||
aggregations.percentile_ranks_int.values: | ||
"50.0": 37.0 | ||
"99.0": 36.5 | ||
|
||
- match: | ||
aggregations.percentile_ranks_double.values: | ||
"50.0": 37.0 | ||
"99.0": 36.5 | ||
|
||
--- | ||
"Only aggs test": | ||
|
||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: [50, 99] | ||
percentile_ranks_double: | ||
percentile_ranks: | ||
field: double_field | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 0 } | ||
- match: | ||
aggregations.percentile_ranks_int.values: | ||
"50.0": 37.0 | ||
"99.0": 36.5 | ||
|
||
- match: | ||
aggregations.percentile_ranks_double.values: | ||
"50.0": 37.0 | ||
"99.0": 36.5 | ||
|
||
--- | ||
"Filtered test": | ||
|
||
- do: | ||
search: | ||
body: | ||
query: | ||
constant_score: | ||
filter: | ||
range: | ||
int_field: | ||
gte: 50 | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: [50] | ||
percentile_ranks_double: | ||
percentile_ranks: | ||
field: double_field | ||
values: [50] | ||
|
||
- match: { hits.total: 3 } | ||
- length: { hits.hits: 3 } | ||
- match: | ||
aggregations.percentile_ranks_int.values: | ||
"50.0": 16.0 | ||
|
||
- match: | ||
aggregations.percentile_ranks_double.values: | ||
"50.0": 16.0 | ||
|
||
--- | ||
"Missing field with missing param": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_missing: | ||
percentile_ranks: | ||
field: missing_field | ||
missing: 1.0 | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: | ||
aggregations.percentile_ranks_missing.values: | ||
"50.0": 100.0 | ||
"99.0": 100.0 | ||
|
||
|
||
--- | ||
"Missing field without missing param": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_missing: | ||
percentile_ranks: | ||
field: missing_field | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- is_false: aggregations.percentile_ranks_missing.value | ||
|
||
--- | ||
"Metadata test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
meta: | ||
foo: bar | ||
percentile_ranks: | ||
field: int_field | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: { aggregations.percentile_ranks_int.meta.foo: "bar" } | ||
- match: | ||
aggregations.percentile_ranks_int.values: | ||
"50.0": 37.0 | ||
"99.0": 36.5 | ||
|
||
--- | ||
"Invalid params test": | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: [] | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: null | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: ["foo"] | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_string: | ||
percentile_ranks: | ||
field: string_field | ||
|
||
--- | ||
"Non-keyed test": | ||
|
||
- do: | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int_field | ||
values: [50, 99] | ||
keyed: false | ||
|
||
|
||
- match: { hits.total: 4 } | ||
- length: { hits.hits: 4 } | ||
- match: | ||
aggregations.percentile_ranks_int.values: | ||
- key: 50.0 | ||
value: 37.0 | ||
- key: 99.0 | ||
value: 36.5 | ||
|
Oops, something went wrong.