Register ip_range aggregation with the high level client (#26383)
The parser for the `ip_range` aggregation response is currently missing from the NamedXContentRegistry in the high level rest client. Also changes the testing around the expected number of parsers so we at least check that we register all the parsers that we also test in InternalAggregationTestCase.
This commit is contained in:
parent
f6bbc91c0d
commit
ad8f359deb
|
@ -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<NamedXContentRegistry.Entry> entries = map.entrySet().stream()
|
||||
.map(entry -> new NamedXContentRegistry.Entry(Aggregation.class, new ParseField(entry.getKey()), entry.getValue()))
|
||||
|
|
|
@ -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<NamedXContentRegistry.Entry> namedXContents = RestHighLevelClient.getDefaultNamedXContents();
|
||||
assertEquals(44, namedXContents.size());
|
||||
int expectedInternalAggregations = InternalAggregationTestCase.getDefaultNamedXContents().size();
|
||||
int expectedSuggestions = 3;
|
||||
assertEquals(expectedInternalAggregations + expectedSuggestions, namedXContents.size());
|
||||
Map<Class<?>, 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() {
|
||||
|
|
Loading…
Reference in New Issue