Skip to content

Commit

Permalink
Add tests for execution_hint in aggregations with percentiles. (#96927)
Browse files Browse the repository at this point in the history
Setting `experiment_hint` to `high_accuracy` leads to using a slower but
more accurate implementation for TDigest.

Add YAML tests to cover for settings this param properly and for parsing
errors.

Related to #95903
  • Loading branch information
kkrik-es authored Jun 21, 2023
1 parent 1a94231 commit bd29706
Show file tree
Hide file tree
Showing 4 changed files with 266 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,49 @@ setup:
- match: { aggregations.mad_int.value: 100 }
- match: { aggregations.mad_double.value: 100 }

---
"with execution hint":

- skip:
version: " - 8.8.99"
reason: t-digest forked in 8.9.0

- do:
search:
body:
aggs:
mad_int:
median_absolute_deviation:
field: int_field
execution_hint: high_accuracy

- match: { hits.total.value: 3 }
- length: { hits.hits: 3 }
- match: { aggregations.mad_int.value: 100 }

- do:
search:
body:
aggs:
mad_int:
median_absolute_deviation:
field: int_field
execution_hint: default

- match: { hits.total.value: 3 }
- length: { hits.hits: 3 }
- match: { aggregations.mad_int.value: 100 }

- do:
catch: /Invalid execution_hint \[no_such_hint\], valid values are \[default, high_accuracy\]/
search:
body:
aggs:
mad:
median_absolute_deviation:
field: int_field
execution_hint: no_such_hint

---
"no documents":

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,78 @@ basic:
- 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} }

---
with compression:
- skip:
features: close_to
version: " - 8.8.99"
reason: t-digest forked in 8.9.0
- do:
search:
body:
size: 0
aggs:
percentile_ranks_int:
percentile_ranks:
field: int
values: [50, 99]
tdigest:
compression: 200

- match: { hits.total.value: 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} }

---
with execution hint:
- skip:
features: close_to
version: " - 8.8.99"
reason: t-digest forked in 8.9.0

- do:
search:
body:
size: 0
aggs:
percentile_ranks_int:
percentile_ranks:
field: int
values: [50, 99]
tdigest:
execution_hint: high_accuracy

- match: { hits.total.value: 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} }

- do:
search:
body:
size: 0
aggs:
percentile_ranks_int:
percentile_ranks:
field: int
values: [ 50, 99 ]
tdigest:
execution_hint: default

- match: { hits.total.value: 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 } }

- do:
catch: /Invalid execution_hint \[no_such_hint\], valid values are \[default, high_accuracy\]/
search:
body:
aggs:
percentile_ranks_string:
percentile_ranks:
field: string
tdigest:
execution_hint: no_such_hint

---
filtered:
- skip:
Expand Down Expand Up @@ -156,6 +228,17 @@ invalid params:
percentile_ranks:
field: string

- do:
catch: /\[compression\] must be greater than or equal to 0. Found \[-1.0\]/
search:
body:
aggs:
percentile_ranks_string:
percentile_ranks:
field: string
tdigest:
compression: -1

---
non-keyed test:
- skip:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,65 @@ setup:
- close_to: { aggregations.percentiles_double.values.95\.0: { value: 146.0, error: 5.0 } }
- close_to: { aggregations.percentiles_double.values.99\.0: { value: 150.0, error: 1.0 } }


---
"Execution hint":
- skip:
features: close_to
version: " - 8.8.99"
reason: t-digest forked in 8.9.0
- do:
search:
body:
aggs:
percentiles_int:
percentiles:
field: int_field
tdigest:
execution_hint: high_accuracy

- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- close_to: { aggregations.percentiles_int.values.1\.0: { value: 5.0, error: 5.0 } }
- close_to: { aggregations.percentiles_int.values.5\.0: { value: 5.0, error: 5.0 } }
- close_to: { aggregations.percentiles_int.values.25\.0: { value: 30.0, error: 10.0 } }
- close_to: { aggregations.percentiles_int.values.50\.0: { value: 76.0, error: 1.0 } }
- close_to: { aggregations.percentiles_int.values.75\.0: { value: 120.0, error: 10.0 } }
- close_to: { aggregations.percentiles_int.values.95\.0: { value: 146.0, error: 5.0 } }
- close_to: { aggregations.percentiles_int.values.99\.0: { value: 150.0, error: 1.0 } }

- do:
search:
body:
aggs:
percentiles_int:
percentiles:
field: int_field
tdigest:
execution_hint: default

- match: { hits.total.value: 4 }
- length: { hits.hits: 4 }
- close_to: { aggregations.percentiles_int.values.1\.0: { value: 5.0, error: 5.0 } }
- close_to: { aggregations.percentiles_int.values.5\.0: { value: 5.0, error: 5.0 } }
- close_to: { aggregations.percentiles_int.values.25\.0: { value: 30.0, error: 10.0 } }
- close_to: { aggregations.percentiles_int.values.50\.0: { value: 76.0, error: 1.0 } }
- close_to: { aggregations.percentiles_int.values.75\.0: { value: 120.0, error: 10.0 } }
- close_to: { aggregations.percentiles_int.values.95\.0: { value: 146.0, error: 5.0 } }
- close_to: { aggregations.percentiles_int.values.99\.0: { value: 150.0, error: 1.0 } }

- do:
catch: /Invalid execution_hint \[no_such_hint\], valid values are \[default, high_accuracy\]/
search:
body:
aggs:
percentiles_int:
percentiles:
field: int_field
tdigest:
execution_hint: no_such_hint


---
"Only aggs test":
- skip:
Expand Down Expand Up @@ -338,7 +397,6 @@ setup:
- do:
catch: /\[compression\] must be greater than or equal to 0. Found \[-1.0\]/
search:
rest_total_hits_as_int: true
body:
aggs:
percentiles_int:
Expand All @@ -350,7 +408,6 @@ setup:
- do:
catch: bad_request
search:
rest_total_hits_as_int: true
body:
aggs:
percentiles_int:
Expand All @@ -361,7 +418,6 @@ setup:
- do:
catch: bad_request
search:
rest_total_hits_as_int: true
body:
aggs:
percentiles_int:
Expand All @@ -372,7 +428,6 @@ setup:
- do:
catch: bad_request
search:
rest_total_hits_as_int: true
body:
aggs:
percentiles_int:
Expand All @@ -383,7 +438,6 @@ setup:
- do:
catch: bad_request
search:
rest_total_hits_as_int: true
body:
aggs:
percentiles_string:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,87 @@ setup:
- match: { aggregations.plot.q2: 5.0 }
- match: { aggregations.plot.q3: 10.0 }

---
"Search With Compression":

- do:
search:
index: "latency"
body:
size: 0
aggs:
plot:
boxplot:
field: "load_time"
compression: 200

- match: { aggregations.plot.min: 2.0 }
- match: { aggregations.plot.max: 15.0 }
- match: { aggregations.plot.q1: 3.0 }
- match: { aggregations.plot.q2: 5.0 }
- match: { aggregations.plot.q3: 10.0 }

- do:
catch: /\[compression\] must be greater than or equal to 0. Found \[-1.0\] in \[plot\]/
search:
index: "latency"
body:
size: 0
aggs:
plot:
boxplot:
field: "load_time"
compression: -1.0

---
"Search With Execution Hint":

- do:
search:
index: "latency"
body:
size: 0
aggs:
plot:
boxplot:
field: "load_time"
execution_hint: high_accuracy

- match: { aggregations.plot.min: 2.0 }
- match: { aggregations.plot.max: 15.0 }
- match: { aggregations.plot.q1: 2.75 }
- match: { aggregations.plot.q2: 5.0 }
- match: { aggregations.plot.q3: 11.25 }

- do:
search:
index: "latency"
body:
size: 0
aggs:
plot:
boxplot:
field: "load_time"
execution_hint: default

- match: { aggregations.plot.min: 2.0 }
- match: { aggregations.plot.max: 15.0 }
- match: { aggregations.plot.q1: 3.0 }
- match: { aggregations.plot.q2: 5.0 }
- match: { aggregations.plot.q3: 10.0 }

- do:
catch: /Invalid execution_hint \[no_such_hint\], valid values are \[default, high_accuracy\]/
search:
index: "latency"
body:
size: 0
aggs:
plot:
boxplot:
field: "load_time"
execution_hint: no_such_hint

---
"Search With Runtime Field":

Expand Down

0 comments on commit bd29706

Please sign in to comment.