diff options
author | qwerty4030 <qwerty4030@gmail.com> | 2017-05-11 10:06:26 -0700 |
---|---|---|
committer | Colin Goodheart-Smithe <colings86@users.noreply.github.com> | 2017-05-11 18:06:26 +0100 |
commit | e7d352b489272a87b05019869857656de7fb82fc (patch) | |
tree | 6d90feba82e3724500e86b51335dcabce4241d78 /rest-api-spec/src/main | |
parent | 952feb58e41bd0220784c44136b840ea4a740e26 (diff) |
Compound order for histogram aggregations. (#22343)
This commit adds support for histogram and date_histogram agg compound order by refactoring and reusing terms agg order code. The major change is that the Terms.Order and Histogram.Order classes have been replaced/refactored into a new class BucketOrder. This is a breaking change for the Java Transport API. For backward compatibility with previous ES versions the (date)histogram compound order will use the first order. Also the _term and _time aggregation order keys have been deprecated; replaced by _key.
Relates to #20003: now that all these aggregations use the same order code, it should be easier to move validation to parse time (as a follow up PR).
Relates to #14771: histogram and date_histogram aggregation order will now be validated at reduce time.
Closes #23613: if a single BucketOrder that is not a tie-breaker is added with the Java Transport API, it will be converted into a CompoundOrder with a tie-breaker.
Diffstat (limited to 'rest-api-spec/src/main')
-rw-r--r-- | rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/10_histogram.yaml | 63 | ||||
-rw-r--r-- | rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/20_terms.yaml | 54 |
2 files changed, 117 insertions, 0 deletions
diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/10_histogram.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/10_histogram.yaml index 63deebcd87..4955dcfb4d 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/10_histogram.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/10_histogram.yaml @@ -10,6 +10,8 @@ setup: "properties": "number": "type" : "integer" + "date": + "type" : "date" - do: cluster.health: wait_for_status: green @@ -143,3 +145,64 @@ setup: - match: { aggregations.histo.buckets.3.key_as_string: "Value is 150.0" } - match: { aggregations.histo.buckets.3.doc_count: 1 } + +--- +"Deprecated _time order": + + - skip: + version: " - 5.99.99" + reason: _time order deprecated in 6.0, replaced by _key + features: "warnings" + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "date" : "2016-01-01" } + + - do: + index: + index: test_1 + type: test + id: 2 + body: { "date" : "2016-01-02" } + + - do: + index: + index: test_1 + type: test + id: 3 + body: { "date" : "2016-02-01" } + + - do: + index: + index: test_1 + type: test + id: 4 + body: { "date" : "2016-03-01" } + + - do: + indices.refresh: {} + + - do: + search: + body: { "aggs" : { "histo" : { "date_histogram" : { "field" : "date", "interval" : "month", "order" : { "_time" : "desc" } } } } } + warnings: + - "Deprecated aggregation order key [_time] used, replaced by [_key]" + + - match: { hits.total: 4 } + + - length: { aggregations.histo.buckets: 3 } + + - match: { aggregations.histo.buckets.0.key_as_string: "2016-03-01T00:00:00.000Z" } + + - match: { aggregations.histo.buckets.0.doc_count: 1 } + + - match: { aggregations.histo.buckets.1.key_as_string: "2016-02-01T00:00:00.000Z" } + + - match: { aggregations.histo.buckets.1.doc_count: 1 } + + - match: { aggregations.histo.buckets.2.key_as_string: "2016-01-01T00:00:00.000Z" } + + - match: { aggregations.histo.buckets.2.doc_count: 2 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/20_terms.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/20_terms.yaml index c9ba94cf61..9cc30bbcd1 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/20_terms.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search.aggregation/20_terms.yaml @@ -747,3 +747,57 @@ setup: - match: { aggregations.number_terms.buckets.2.key: 14.6 } - match: { aggregations.number_terms.buckets.2.doc_count: 1 } + +--- +"Deprecated _term order": + + - skip: + version: " - 5.99.99" + reason: _term order deprecated in 6.0, replaced by _key + features: "warnings" + + - do: + index: + index: test_1 + type: test + id: 1 + body: { "str": "abc" } + + - do: + index: + index: test_1 + type: test + id: 2 + body: { "str": "abc" } + + - do: + index: + index: test_1 + type: test + id: 3 + body: { "str": "bcd" } + + - do: + indices.refresh: {} + + - do: + search: + body: { "size" : 0, "aggs" : { "str_terms" : { "terms" : { "field" : "str", "order" : { "_term" : "desc" } } } } } + warnings: + - "Deprecated aggregation order key [_term] used, replaced by [_key]" + + - match: { hits.total: 3 } + + - length: { aggregations.str_terms.buckets: 2 } + + - match: { aggregations.str_terms.buckets.0.key: "bcd" } + + - is_false: aggregations.str_terms.buckets.0.key_as_string + + - match: { aggregations.str_terms.buckets.0.doc_count: 1 } + + - match: { aggregations.str_terms.buckets.1.key: "abc" } + + - is_false: aggregations.str_terms.buckets.1.key_as_string + + - match: { aggregations.str_terms.buckets.1.doc_count: 2 } |