Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YAML REST tests for percentile_ranks metric aggregation #27127

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Loading