From b5a58ece41a48f18275fffd1e3965b0319dbd05f Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Thu, 14 Apr 2016 16:25:49 -0400 Subject: [PATCH] Cut nested and reverse_nested aggregations to registerAggregation and remove their PROTOTYPES. Relates to #17085 --- .../elasticsearch/search/SearchModule.java | 9 +-- .../nested/NestedAggregatorBuilder.java | 69 ++++++++++++++---- .../bucket/nested/NestedParser.java | 72 ------------------- .../ReverseNestedAggregatorBuilder.java | 67 ++++++++++++++--- .../bucket/nested/ReverseNestedParser.java | 72 ------------------- 5 files changed, 118 insertions(+), 171 deletions(-) delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedParser.java delete mode 100644 core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/ReverseNestedParser.java diff --git a/core/src/main/java/org/elasticsearch/search/SearchModule.java b/core/src/main/java/org/elasticsearch/search/SearchModule.java index 1318ac8ae1e..a597c9bf1b6 100644 --- a/core/src/main/java/org/elasticsearch/search/SearchModule.java +++ b/core/src/main/java/org/elasticsearch/search/SearchModule.java @@ -120,8 +120,8 @@ import org.elasticsearch.search.aggregations.bucket.missing.InternalMissing; import org.elasticsearch.search.aggregations.bucket.missing.MissingParser; import org.elasticsearch.search.aggregations.bucket.nested.InternalNested; import org.elasticsearch.search.aggregations.bucket.nested.InternalReverseNested; -import org.elasticsearch.search.aggregations.bucket.nested.NestedParser; -import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedParser; +import org.elasticsearch.search.aggregations.bucket.nested.NestedAggregatorBuilder; +import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedAggregatorBuilder; import org.elasticsearch.search.aggregations.bucket.range.InternalRange; import org.elasticsearch.search.aggregations.bucket.range.RangeAggregatorBuilder; import org.elasticsearch.search.aggregations.bucket.range.RangeParser; @@ -474,8 +474,9 @@ public class SearchModule extends AbstractModule { DateHistogramAggregatorBuilder.AGGREGATION_NAME_FIELD); registerAggregatorParser(new GeoDistanceParser()); registerAggregatorParser(new GeoHashGridParser()); - registerAggregatorParser(new NestedParser()); - registerAggregatorParser(new ReverseNestedParser()); + registerAggregation(NestedAggregatorBuilder::new, NestedAggregatorBuilder::parse, NestedAggregatorBuilder.AGGREGATION_FIELD_NAME); + registerAggregation(ReverseNestedAggregatorBuilder::new, ReverseNestedAggregatorBuilder::parse, + ReverseNestedAggregatorBuilder.AGGREGATION_NAME_FIELD); registerAggregatorParser(new TopHitsParser()); registerAggregatorParser(new GeoBoundsParser()); registerAggregatorParser(new GeoCentroidParser()); diff --git a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorBuilder.java b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorBuilder.java index 724eaec09ab..a0b17701ed1 100644 --- a/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorBuilder.java @@ -19,20 +19,24 @@ package org.elasticsearch.search.aggregations.bucket.nested; +import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.ParsingException; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.xcontent.XContentBuilder; +import org.elasticsearch.common.xcontent.XContentParser; +import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.search.aggregations.AggregatorBuilder; -import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.AggregatorFactories.Builder; +import org.elasticsearch.search.aggregations.AggregatorFactory; import org.elasticsearch.search.aggregations.support.AggregationContext; import java.io.IOException; import java.util.Objects; public class NestedAggregatorBuilder extends AggregatorBuilder { - - static final NestedAggregatorBuilder PROTOTYPE = new NestedAggregatorBuilder("", ""); + public static final String NAME = InternalNested.TYPE.name(); + public static final ParseField AGGREGATION_FIELD_NAME = new ParseField(NAME); private final String path; @@ -51,6 +55,24 @@ public class NestedAggregatorBuilder extends AggregatorBuilder { - - static final ReverseNestedAggregatorBuilder PROTOTYPE = new ReverseNestedAggregatorBuilder(""); + public static final String NAME = InternalReverseNested.TYPE.name(); + public static final ParseField AGGREGATION_NAME_FIELD = new ParseField(NAME); private String path; @@ -40,6 +44,24 @@ public class ReverseNestedAggregatorBuilder extends AggregatorBuilder