We used to have a *ton* off stuff in the `AggParseContext` but now we parse aggs entirely with named xcontent. So we don't need the context any more.
This commit is contained in:
parent
f52af7977d
commit
76bb661023
|
@ -101,7 +101,6 @@ import org.elasticsearch.plugins.SearchPlugin.SearchExtensionSpec;
|
||||||
import org.elasticsearch.plugins.SearchPlugin.SignificanceHeuristicSpec;
|
import org.elasticsearch.plugins.SearchPlugin.SignificanceHeuristicSpec;
|
||||||
import org.elasticsearch.plugins.SearchPlugin.SuggesterSpec;
|
import org.elasticsearch.plugins.SearchPlugin.SuggesterSpec;
|
||||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
|
||||||
import org.elasticsearch.search.aggregations.BaseAggregationBuilder;
|
import org.elasticsearch.search.aggregations.BaseAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.InternalAggregation;
|
import org.elasticsearch.search.aggregations.InternalAggregation;
|
||||||
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
import org.elasticsearch.search.aggregations.PipelineAggregationBuilder;
|
||||||
|
@ -462,8 +461,8 @@ public class SearchModule {
|
||||||
private void registerAggregation(AggregationSpec spec) {
|
private void registerAggregation(AggregationSpec spec) {
|
||||||
if (false == transportClient) {
|
if (false == transportClient) {
|
||||||
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
|
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
|
||||||
AggregatorFactories.AggParseContext context = (AggregatorFactories.AggParseContext) c;
|
String name = (String) c;
|
||||||
return spec.getParser().parse(context.name, p);
|
return spec.getParser().parse(name, p);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
namedWriteables.add(
|
namedWriteables.add(
|
||||||
|
@ -569,8 +568,8 @@ public class SearchModule {
|
||||||
private void registerPipelineAggregation(PipelineAggregationSpec spec) {
|
private void registerPipelineAggregation(PipelineAggregationSpec spec) {
|
||||||
if (false == transportClient) {
|
if (false == transportClient) {
|
||||||
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
|
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
|
||||||
AggregatorFactories.AggParseContext context = (AggregatorFactories.AggParseContext) c;
|
String name = (String) c;
|
||||||
return spec.getParser().parse(context.name, p);
|
return spec.getParser().parse(name, p);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
namedWriteables.add(
|
namedWriteables.add(
|
||||||
|
|
|
@ -119,8 +119,7 @@ public class AggregatorFactories {
|
||||||
+ aggregationName + "]: [" + aggBuilder.getType() + "] and [" + fieldName + "]");
|
+ aggregationName + "]: [" + aggBuilder.getType() + "] and [" + fieldName + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
aggBuilder = parser.namedObject(BaseAggregationBuilder.class, fieldName,
|
aggBuilder = parser.namedObject(BaseAggregationBuilder.class, fieldName, aggregationName);
|
||||||
new AggParseContext(aggregationName));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.START_OBJECT + "] under ["
|
throw new ParsingException(parser.getTokenLocation(), "Expected [" + XContentParser.Token.START_OBJECT + "] under ["
|
||||||
|
@ -151,17 +150,6 @@ public class AggregatorFactories {
|
||||||
return factories;
|
return factories;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Context to parse and aggregation. This should eventually be removed and replaced with a String.
|
|
||||||
*/
|
|
||||||
public static final class AggParseContext {
|
|
||||||
public final String name;
|
|
||||||
|
|
||||||
public AggParseContext(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final AggregatorFactories EMPTY = new AggregatorFactories(new AggregatorFactory[0], new ArrayList<>());
|
public static final AggregatorFactories EMPTY = new AggregatorFactories(new AggregatorFactory[0], new ArrayList<>());
|
||||||
|
|
||||||
private AggregatorFactory[] factories;
|
private AggregatorFactory[] factories;
|
||||||
|
|
Loading…
Reference in New Issue