-
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.
Browse files
Browse the repository at this point in the history
* Add integration test for percentile_ranks (#77815) This revives #27127, modernizing it to include stuff like `close_to`. * Backport update
- Loading branch information
Showing
2 changed files
with
420 additions
and
0 deletions.
There are no files selected for viewing
185 changes: 185 additions & 0 deletions
185
...t/resources/rest-api-spec/test/search.aggregation/420_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,185 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
int: | ||
type : integer | ||
double: | ||
type : double | ||
keyword: | ||
type: keyword | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
index: test | ||
body: | ||
- '{"index": {}}' | ||
- '{"int": 1, "double": 1.0, "keyword": "foo"}' | ||
- '{"index": {}}' | ||
- '{"int": 51, "double": 51.0, "keyword": "foo"}' | ||
- '{"index": {}}' | ||
- '{"int": 101, "double": 101.0, "keyword": "foo"}' | ||
- '{"index": {}}' | ||
- '{"int": 151, "double": 151.0, "keyword": "foo"}' | ||
|
||
--- | ||
basic: | ||
- skip: | ||
features: close_to | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
body: | ||
size: 0 | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int | ||
values: [50, 99] | ||
percentile_ranks_double: | ||
percentile_ranks: | ||
field: double | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- close_to: { aggregations.percentile_ranks_int.values.50\\.0: { value: 37.0, error: 1} } | ||
- close_to: { aggregations.percentile_ranks_int.values.99\\.0: { value: 61.5, error: 1} } | ||
- close_to: { aggregations.percentile_ranks_double.values.50\\.0: { value: 37.0, error: 1} } | ||
- close_to: { aggregations.percentile_ranks_double.values.99\\.0: { value: 61.5, error: 1} } | ||
|
||
--- | ||
filtered: | ||
- skip: | ||
features: close_to | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
body: | ||
size: 0 | ||
query: | ||
range: | ||
int: | ||
gte: 50 | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int | ||
values: [50] | ||
percentile_ranks_double: | ||
percentile_ranks: | ||
field: double | ||
values: [50] | ||
|
||
- match: { hits.total: 3 } | ||
- close_to: { aggregations.percentile_ranks_int.values.50\\.0: { value: 16.0, error: 1} } | ||
- close_to: { aggregations.percentile_ranks_double.values.50\\.0: { value: 16.0, error: 1} } | ||
|
||
--- | ||
missing field with missing param: | ||
- skip: | ||
features: close_to | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
body: | ||
size: 0 | ||
aggs: | ||
percentile_ranks_missing: | ||
percentile_ranks: | ||
field: missing | ||
missing: 1.0 | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- close_to: { aggregations.percentile_ranks_missing.values.50\\.0: { value: 100.0, error: 1} } | ||
- close_to: { aggregations.percentile_ranks_missing.values.99\\.0: { value: 100.0, error: 1} } | ||
|
||
--- | ||
missing field without missing param: | ||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
body: | ||
size: 0 | ||
aggs: | ||
percentile_ranks_missing: | ||
percentile_ranks: | ||
field: missing | ||
values: [50, 99] | ||
|
||
- match: { hits.total: 4 } | ||
- is_false: aggregations.percentile_ranks_missing.value | ||
|
||
--- | ||
invalid params: | ||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int | ||
values: [] | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int | ||
values: null | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int | ||
values: ["foo"] | ||
|
||
- do: | ||
catch: bad_request | ||
search: | ||
body: | ||
aggs: | ||
percentile_ranks_string: | ||
percentile_ranks: | ||
field: string | ||
|
||
--- | ||
non-keyed test: | ||
- skip: | ||
features: close_to | ||
|
||
- do: | ||
search: | ||
rest_total_hits_as_int: true | ||
body: | ||
size: 0 | ||
aggs: | ||
percentile_ranks_int: | ||
percentile_ranks: | ||
field: int | ||
values: [50, 99] | ||
keyed: false | ||
|
||
- match: { hits.total: 4 } | ||
- match: { aggregations.percentile_ranks_int.values.0.key: 50} | ||
- close_to: { aggregations.percentile_ranks_int.values.0.value: { value: 37.0, error: 1} } | ||
- match: { aggregations.percentile_ranks_int.values.1.key: 99} | ||
- close_to: { aggregations.percentile_ranks_int.values.1.value: { value: 61.5, error: 1} } | ||
|
Oops, something went wrong.