diff options
author | Tanguy Leroux <tlrx.dev@gmail.com> | 2017-05-05 20:00:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-05 20:00:39 +0200 |
commit | 7bd2abe48af5a651b54bcd5bcb41c88e29390be0 (patch) | |
tree | 1259637fa917d6b4be0c851279f1801fd70cc559 /core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java | |
parent | 0b36fb052c10eea5b248bfab71e5caffaf51ef92 (diff) |
Change Terms.Bucket to an interface (#24492)
This commit changes the Terms.Bucket abstract class to an interface, so
that it's easier for the Java High Level Rest Client to provide its own
implementation.
In its current state, the Terms.Bucket abstract class inherits from
InternalMultiBucketAggregation.InternalBucket which forces subclasses to
implement Writeable and exposes a public getProperty() method that relies
on InternalAggregation. This two points make it difficult for the Java
High Level Rest Client to implement the Terms and Terms.Bucket correctly.
This is also different from other MultiBucketsAggregation like Range
which are pure interfaces.
Changing Terms.Bucket to an interface causes a method clashes for the
`getBuckets()` method in InternalTerms. This is because:
- InternalTerms implements Terms which declared a
`List<Terms.Bucket> getBuckets()` method
- InternalTerms extends InternalMultiBucketAggregation which declares a
`List<? extends InternalBucket> getBuckets()` method
- both overrides the MultiBucketsAggregation
`List<? extends Bucket> getBuckets()` method
There was no clashes before this change because Terms.Bucket extends
InternalBucket and conformed to both declaration. With Terms.Bucket now
an interface, the getBuckets() method in the Terms interface is changed
to avoid method clash. This is a breaking change in the Java API but
it's a straightforward change and the Terms multi bucket aggregation
interface is also more coherent with the other Range, Histogram,
Filters, AdjacencyMatrix etc that all return a `List<? extends Bucket>`.
Diffstat (limited to 'core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java')
-rw-r--r-- | core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java index 7de7bb0f31..3903dd8b0b 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/ExtendedStatsIT.java @@ -604,7 +604,7 @@ public class ExtendedStatsIT extends AbstractNumericTestCase { Terms terms = searchResponse.getAggregations().get("terms"); assertThat(terms, notNullValue()); - List<Terms.Bucket> buckets = terms.getBuckets(); + List<? extends Terms.Bucket> buckets = terms.getBuckets(); assertThat(buckets, notNullValue()); assertThat(buckets.size(), equalTo(10)); |