forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up how pipeline aggs check for multi-bucket (elastic#54161)
Pipeline aggregations like `stats_bucket`, `sum_bucket`, and `percentiles_bucket` only operate on buckets that have multiple buckets. This adds support for those aggregations to `geo_distance`, `ip_range`, `auto_date_histogram`, and `rare_terms`. This all happened because we used a marker interface to mark compatible aggs, `MultiBucketAggregationBuilder` and it was fairly easy to forget to implement the interface. This replaces the marker interface with an abstract method in `AggregationBuilder`, `bucketCardinality` which makes you return `NONE`, `ONE`, or `MANY`. The `bucket` aggregations can check for `MANY`. At this point `ONE` and `NONE` amount to about the same thing, but I suspect that'll be a useful distinction when validating bucket sorts. Closes elastic#53215
- Loading branch information
Showing
45 changed files
with
518 additions
and
103 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
73 changes: 73 additions & 0 deletions
73
...spec/src/main/resources/rest-api-spec/test/search.aggregation/330_auto_date_histogram.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,73 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
number_of_replicas: 0 | ||
mappings: | ||
properties: | ||
date: | ||
type: date | ||
- do: | ||
bulk: | ||
refresh: true | ||
index: test | ||
body: | ||
- '{"index": {}}' | ||
- '{"date": "2020-03-01", "v": 1}' | ||
- '{"index": {}}' | ||
- '{"date": "2020-03-02", "v": 2}' | ||
- '{"index": {}}' | ||
- '{"date": "2020-03-08", "v": 3}' | ||
- '{"index": {}}' | ||
- '{"date": "2020-03-09", "v": 4}' | ||
|
||
--- | ||
"basic": | ||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
histo: | ||
auto_date_histogram: | ||
field: date | ||
buckets: 2 | ||
- match: { hits.total.value: 4 } | ||
- length: { aggregations.histo.buckets: 2 } | ||
- match: { aggregations.histo.buckets.0.key_as_string: "2020-03-01T00:00:00.000Z" } | ||
- match: { aggregations.histo.buckets.0.doc_count: 2 } | ||
- match: { aggregations.histo.buckets.1.key_as_string: "2020-03-08T00:00:00.000Z" } | ||
- match: { aggregations.histo.buckets.1.doc_count: 2 } | ||
|
||
--- | ||
"avg_bucket": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: Fixed in 8.0.0 to be backported to 7.8.0 | ||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
histo: | ||
auto_date_histogram: | ||
field: date | ||
buckets: 2 | ||
aggs: | ||
v: | ||
sum: | ||
field: v | ||
histo_avg_v: | ||
avg_bucket: | ||
buckets_path: histo.v | ||
- match: { hits.total.value: 4 } | ||
- length: { aggregations.histo.buckets: 2 } | ||
- match: { aggregations.histo.buckets.0.key_as_string: "2020-03-01T00:00:00.000Z" } | ||
- match: { aggregations.histo.buckets.0.doc_count: 2 } | ||
- match: { aggregations.histo.buckets.0.v.value: 3 } | ||
- match: { aggregations.histo.buckets.1.key_as_string: "2020-03-08T00:00:00.000Z" } | ||
- match: { aggregations.histo.buckets.1.doc_count: 2 } | ||
- match: { aggregations.histo.buckets.1.v.value: 7 } | ||
- match: { aggregations.histo_avg_v.value: 5 } |
84 changes: 84 additions & 0 deletions
84
rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/340_geo_distance.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,84 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
properties: | ||
location: | ||
type: geo_point | ||
- do: | ||
bulk: | ||
index: test | ||
refresh: true | ||
body: | ||
- '{"index": {}}' | ||
- '{"location": {"lat" : 40.7128, "lon" : -74.0060}, "name": "New York", "population": 8623000}' | ||
- '{"index": {}}' | ||
- '{"location": {"lat" : 34.0522, "lon" : -118.2437}, "name": "Los Angeles", "population": 4000000}' | ||
- '{"index": {}}' | ||
- '{"location": {"lat" : 41.8781, "lon" : -87.6298}, "name": "Chicago", "population": 2716000}' | ||
|
||
--- | ||
"basic": | ||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
distance: | ||
geo_distance: | ||
field: location | ||
origin: "35.7796, -78.6382" | ||
ranges: | ||
- to: 1000000 | ||
- from: 1000000 | ||
to: 5000000 | ||
- from: 5000000 | ||
- match: { hits.total.value: 3 } | ||
- length: { aggregations.distance.buckets: 3 } | ||
- match: { aggregations.distance.buckets.0.key: "*-1000000.0" } | ||
- match: { aggregations.distance.buckets.0.doc_count: 1 } | ||
- match: { aggregations.distance.buckets.1.key: "1000000.0-5000000.0" } | ||
- match: { aggregations.distance.buckets.1.doc_count: 2 } | ||
- match: { aggregations.distance.buckets.2.key: "5000000.0-*" } | ||
- match: { aggregations.distance.buckets.2.doc_count: 0 } | ||
|
||
--- | ||
"avg_bucket": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: Fixed in 8.0.0 to be backported to 7.8.0 | ||
- do: | ||
search: | ||
body: | ||
size: 0 | ||
aggs: | ||
distance: | ||
geo_distance: | ||
field: location | ||
origin: "35.7796, -78.6382" | ||
ranges: | ||
- to: 1000000 | ||
- from: 1000000 | ||
to: 5000000 | ||
- from: 5000000 | ||
aggs: | ||
total_population: | ||
sum: | ||
field: population | ||
avg_total_population: | ||
avg_bucket: | ||
buckets_path: distance.total_population | ||
- match: { hits.total.value: 3 } | ||
- length: { aggregations.distance.buckets: 3 } | ||
- match: { aggregations.distance.buckets.0.key: "*-1000000.0" } | ||
- match: { aggregations.distance.buckets.0.doc_count: 1 } | ||
- match: { aggregations.distance.buckets.0.total_population.value: 8623000.0 } | ||
- match: { aggregations.distance.buckets.1.key: "1000000.0-5000000.0" } | ||
- match: { aggregations.distance.buckets.1.doc_count: 2 } | ||
- match: { aggregations.distance.buckets.1.total_population.value: 6716000.0 } | ||
- match: { aggregations.distance.buckets.2.key: "5000000.0-*" } | ||
- match: { aggregations.distance.buckets.2.doc_count: 0 } | ||
- match: { aggregations.distance.buckets.2.total_population.value: 0 } | ||
- match: { aggregations.avg_total_population.value: 7669500.0 } |
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
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
Oops, something went wrong.