diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java index 80045a233dc..13bf6b81329 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RestHighLevelClient.java @@ -76,6 +76,8 @@ import org.elasticsearch.search.aggregations.bucket.nested.ParsedReverseNested; import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.range.DateRangeAggregationBuilder; import org.elasticsearch.search.aggregations.bucket.range.GeoDistanceAggregationBuilder; +import org.elasticsearch.search.aggregations.bucket.range.IpRangeAggregationBuilder; +import org.elasticsearch.search.aggregations.bucket.range.ParsedBinaryRange; import org.elasticsearch.search.aggregations.bucket.range.ParsedDateRange; import org.elasticsearch.search.aggregations.bucket.range.ParsedGeoDistance; import org.elasticsearch.search.aggregations.bucket.range.ParsedRange; @@ -604,6 +606,7 @@ public class RestHighLevelClient implements Closeable { map.put(SignificantLongTerms.NAME, (p, c) -> ParsedSignificantLongTerms.fromXContent(p, (String) c)); map.put(SignificantStringTerms.NAME, (p, c) -> ParsedSignificantStringTerms.fromXContent(p, (String) c)); map.put(ScriptedMetricAggregationBuilder.NAME, (p, c) -> ParsedScriptedMetric.fromXContent(p, (String) c)); + map.put(IpRangeAggregationBuilder.NAME, (p, c) -> ParsedBinaryRange.fromXContent(p, (String) c)); map.put(TopHitsAggregationBuilder.NAME, (p, c) -> ParsedTopHits.fromXContent(p, (String) c)); List entries = map.entrySet().stream() .map(entry -> new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(entry.getKey()), entry.getValue())) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index 8c655c7289d..beac1c8bf6b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -20,20 +20,7 @@ package org.elasticsearch.client; import com.fasterxml.jackson.core.JsonParseException; -import org.elasticsearch.client.http.Header; -import org.elasticsearch.client.http.HttpEntity; -import org.elasticsearch.client.http.HttpHost; -import org.elasticsearch.client.http.HttpResponse; -import org.elasticsearch.client.http.ProtocolVersion; -import org.elasticsearch.client.http.RequestLine; -import org.elasticsearch.client.http.StatusLine; -import org.elasticsearch.client.http.entity.ByteArrayEntity; -import org.elasticsearch.client.http.entity.ContentType; -import org.elasticsearch.client.http.entity.StringEntity; -import org.elasticsearch.client.http.message.BasicHttpResponse; -import org.elasticsearch.client.http.message.BasicRequestLine; -import org.elasticsearch.client.http.message.BasicStatusLine; -import org.elasticsearch.client.http.nio.entity.NStringEntity; + import org.elasticsearch.Build; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; @@ -48,6 +35,20 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponseSections; import org.elasticsearch.action.search.SearchScrollRequest; import org.elasticsearch.action.search.ShardSearchFailure; +import org.elasticsearch.client.http.Header; +import org.elasticsearch.client.http.HttpEntity; +import org.elasticsearch.client.http.HttpHost; +import org.elasticsearch.client.http.HttpResponse; +import org.elasticsearch.client.http.ProtocolVersion; +import org.elasticsearch.client.http.RequestLine; +import org.elasticsearch.client.http.StatusLine; +import org.elasticsearch.client.http.entity.ByteArrayEntity; +import org.elasticsearch.client.http.entity.ContentType; +import org.elasticsearch.client.http.entity.StringEntity; +import org.elasticsearch.client.http.message.BasicHttpResponse; +import org.elasticsearch.client.http.message.BasicRequestLine; +import org.elasticsearch.client.http.message.BasicStatusLine; +import org.elasticsearch.client.http.nio.entity.NStringEntity; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.common.CheckedFunction; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -64,6 +65,7 @@ import org.elasticsearch.search.aggregations.InternalAggregations; import org.elasticsearch.search.aggregations.matrix.stats.MatrixStatsAggregationBuilder; import org.elasticsearch.search.suggest.Suggest; import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.test.InternalAggregationTestCase; import org.junit.Before; import org.mockito.ArgumentMatcher; import org.mockito.internal.matchers.ArrayEquals; @@ -628,7 +630,9 @@ public class RestHighLevelClientTests extends ESTestCase { public void testDefaultNamedXContents() { List namedXContents = RestHighLevelClient.getDefaultNamedXContents(); - assertEquals(44, namedXContents.size()); + int expectedInternalAggregations = InternalAggregationTestCase.getDefaultNamedXContents().size(); + int expectedSuggestions = 3; + assertEquals(expectedInternalAggregations + expectedSuggestions, namedXContents.size()); Map, Integer> categories = new HashMap<>(); for (NamedXContentRegistry.Entry namedXContent : namedXContents) { Integer counter = categories.putIfAbsent(namedXContent.categoryClass, 1); @@ -637,8 +641,8 @@ public class RestHighLevelClientTests extends ESTestCase { } } assertEquals(2, categories.size()); - assertEquals(Integer.valueOf(41), categories.get(Aggregation.class)); - assertEquals(Integer.valueOf(3), categories.get(Suggest.Suggestion.class)); + assertEquals(expectedInternalAggregations, categories.get(Aggregation.class).intValue()); + assertEquals(expectedSuggestions, categories.get(Suggest.Suggestion.class).intValue()); } public void testProvidedNamedXContents() {