mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 09:28:27 +00:00
This commit is contained in:
parent
22a8b60187
commit
87b4979c24
@ -126,8 +126,9 @@ public interface SearchPlugin {
|
||||
/**
|
||||
* Allows plugins to register new aggregations using aggregation names that are already defined
|
||||
* in Core, as long as the new aggregations target different ValuesSourceTypes
|
||||
* @return A list of the new registrar functions
|
||||
*/
|
||||
default List<Consumer<ValuesSourceRegistry>> getBareAggregatorRegistrar() {
|
||||
default List<Consumer<ValuesSourceRegistry.Builder>> getAggregationExtentions() {
|
||||
return emptyList();
|
||||
}
|
||||
/**
|
||||
@ -268,7 +269,7 @@ public interface SearchPlugin {
|
||||
*/
|
||||
class AggregationSpec extends SearchExtensionSpec<AggregationBuilder, ContextParser<String, ? extends AggregationBuilder>> {
|
||||
private final Map<String, Writeable.Reader<? extends InternalAggregation>> resultReaders = new TreeMap<>();
|
||||
private Consumer<ValuesSourceRegistry> aggregatorRegistrar;
|
||||
private Consumer<ValuesSourceRegistry.Builder> aggregatorRegistrar;
|
||||
|
||||
/**
|
||||
* Specification for an {@link Aggregation}.
|
||||
@ -356,7 +357,7 @@ public interface SearchPlugin {
|
||||
* Get the function to register the {@link org.elasticsearch.search.aggregations.support.ValuesSource} to aggregator mappings for
|
||||
* this aggregation
|
||||
*/
|
||||
public Consumer<ValuesSourceRegistry> getAggregatorRegistrar() {
|
||||
public Consumer<ValuesSourceRegistry.Builder> getAggregatorRegistrar() {
|
||||
return aggregatorRegistrar;
|
||||
}
|
||||
|
||||
@ -364,7 +365,7 @@ public interface SearchPlugin {
|
||||
* Set the function to register the {@link org.elasticsearch.search.aggregations.support.ValuesSource} to aggregator mappings for
|
||||
* this aggregation
|
||||
*/
|
||||
public AggregationSpec setAggregatorRegistrar(Consumer<ValuesSourceRegistry> aggregatorRegistrar) {
|
||||
public AggregationSpec setAggregatorRegistrar(Consumer<ValuesSourceRegistry.Builder> aggregatorRegistrar) {
|
||||
this.aggregatorRegistrar = aggregatorRegistrar;
|
||||
return this;
|
||||
}
|
||||
|
@ -322,7 +322,6 @@ public class SearchModule {
|
||||
public SearchModule(Settings settings, boolean transportClient, List<SearchPlugin> plugins) {
|
||||
this.settings = settings;
|
||||
this.transportClient = transportClient;
|
||||
this.valuesSourceRegistry = new ValuesSourceRegistry();
|
||||
registerSuggesters(plugins);
|
||||
highlighters = setupHighlighters(settings, plugins);
|
||||
registerScoreFunctions(plugins);
|
||||
@ -331,8 +330,8 @@ public class SearchModule {
|
||||
registerSorts();
|
||||
registerValueFormats();
|
||||
registerSignificanceHeuristics(plugins);
|
||||
this.valuesSourceRegistry = registerAggregations(plugins);
|
||||
registerMovingAverageModels(plugins);
|
||||
registerAggregations(plugins);
|
||||
registerPipelineAggregations(plugins);
|
||||
registerFetchSubPhases(plugins);
|
||||
registerSearchExts(plugins);
|
||||
@ -367,140 +366,149 @@ public class SearchModule {
|
||||
return movingAverageModelParserRegistry;
|
||||
}
|
||||
|
||||
private void registerAggregations(List<SearchPlugin> plugins) {
|
||||
private ValuesSourceRegistry registerAggregations(List<SearchPlugin> plugins) {
|
||||
ValuesSourceRegistry.Builder builder = new ValuesSourceRegistry.Builder();
|
||||
registerAggregation(new AggregationSpec(AvgAggregationBuilder.NAME, AvgAggregationBuilder::new, AvgAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalAvg::new)
|
||||
.setAggregatorRegistrar(AvgAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(AvgAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(WeightedAvgAggregationBuilder.NAME, WeightedAvgAggregationBuilder::new,
|
||||
WeightedAvgAggregationBuilder.PARSER).addResultReader(InternalWeightedAvg::new));
|
||||
WeightedAvgAggregationBuilder.PARSER).addResultReader(InternalWeightedAvg::new), builder);
|
||||
registerAggregation(new AggregationSpec(SumAggregationBuilder.NAME, SumAggregationBuilder::new, SumAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalSum::new)
|
||||
.setAggregatorRegistrar(SumAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(SumAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(MinAggregationBuilder.NAME, MinAggregationBuilder::new, MinAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalMin::new)
|
||||
.setAggregatorRegistrar(MinAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(MinAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(MaxAggregationBuilder.NAME, MaxAggregationBuilder::new, MaxAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalMax::new)
|
||||
.setAggregatorRegistrar(MaxAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(MaxAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(StatsAggregationBuilder.NAME, StatsAggregationBuilder::new, StatsAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalStats::new)
|
||||
.setAggregatorRegistrar(StatsAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(StatsAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(ExtendedStatsAggregationBuilder.NAME, ExtendedStatsAggregationBuilder::new,
|
||||
ExtendedStatsAggregationBuilder.PARSER).addResultReader(InternalExtendedStats::new));
|
||||
ExtendedStatsAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalExtendedStats::new)
|
||||
.setAggregatorRegistrar(ExtendedStatsAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(ValueCountAggregationBuilder.NAME, ValueCountAggregationBuilder::new,
|
||||
ValueCountAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalValueCount::new)
|
||||
.setAggregatorRegistrar(ValueCountAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(ValueCountAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(PercentilesAggregationBuilder.NAME, PercentilesAggregationBuilder::new,
|
||||
PercentilesAggregationBuilder::parse)
|
||||
.addResultReader(InternalTDigestPercentiles.NAME, InternalTDigestPercentiles::new)
|
||||
.addResultReader(InternalHDRPercentiles.NAME, InternalHDRPercentiles::new)
|
||||
.setAggregatorRegistrar(PercentilesAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(PercentilesAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(PercentileRanksAggregationBuilder.NAME, PercentileRanksAggregationBuilder::new,
|
||||
PercentileRanksAggregationBuilder::parse)
|
||||
.addResultReader(InternalTDigestPercentileRanks.NAME, InternalTDigestPercentileRanks::new)
|
||||
.addResultReader(InternalHDRPercentileRanks.NAME, InternalHDRPercentileRanks::new)
|
||||
.setAggregatorRegistrar(PercentileRanksAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(PercentileRanksAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(MedianAbsoluteDeviationAggregationBuilder.NAME,
|
||||
MedianAbsoluteDeviationAggregationBuilder::new, MedianAbsoluteDeviationAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalMedianAbsoluteDeviation::new)
|
||||
.setAggregatorRegistrar(MedianAbsoluteDeviationAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(MedianAbsoluteDeviationAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(CardinalityAggregationBuilder.NAME, CardinalityAggregationBuilder::new,
|
||||
CardinalityAggregationBuilder.PARSER).addResultReader(InternalCardinality::new)
|
||||
.setAggregatorRegistrar(CardinalityAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(CardinalityAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(GlobalAggregationBuilder.NAME, GlobalAggregationBuilder::new,
|
||||
GlobalAggregationBuilder::parse).addResultReader(InternalGlobal::new));
|
||||
GlobalAggregationBuilder::parse).addResultReader(InternalGlobal::new), builder);
|
||||
registerAggregation(new AggregationSpec(MissingAggregationBuilder.NAME, MissingAggregationBuilder::new,
|
||||
MissingAggregationBuilder.PARSER).addResultReader(InternalMissing::new));
|
||||
MissingAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalMissing::new)
|
||||
.setAggregatorRegistrar(MissingAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(FilterAggregationBuilder.NAME, FilterAggregationBuilder::new,
|
||||
FilterAggregationBuilder::parse).addResultReader(InternalFilter::new));
|
||||
FilterAggregationBuilder::parse).addResultReader(InternalFilter::new), builder);
|
||||
registerAggregation(new AggregationSpec(FiltersAggregationBuilder.NAME, FiltersAggregationBuilder::new,
|
||||
FiltersAggregationBuilder::parse).addResultReader(InternalFilters::new));
|
||||
FiltersAggregationBuilder::parse).addResultReader(InternalFilters::new), builder);
|
||||
registerAggregation(new AggregationSpec(AdjacencyMatrixAggregationBuilder.NAME, AdjacencyMatrixAggregationBuilder::new,
|
||||
AdjacencyMatrixAggregationBuilder::parse).addResultReader(InternalAdjacencyMatrix::new));
|
||||
AdjacencyMatrixAggregationBuilder::parse).addResultReader(InternalAdjacencyMatrix::new), builder);
|
||||
registerAggregation(new AggregationSpec(SamplerAggregationBuilder.NAME, SamplerAggregationBuilder::new,
|
||||
SamplerAggregationBuilder::parse)
|
||||
.addResultReader(InternalSampler.NAME, InternalSampler::new)
|
||||
.addResultReader(UnmappedSampler.NAME, UnmappedSampler::new));
|
||||
.addResultReader(UnmappedSampler.NAME, UnmappedSampler::new),
|
||||
builder);
|
||||
registerAggregation(new AggregationSpec(DiversifiedAggregationBuilder.NAME, DiversifiedAggregationBuilder::new,
|
||||
DiversifiedAggregationBuilder.PARSER)
|
||||
/* Reuses result readers from SamplerAggregator*/);
|
||||
/* Reuses result readers from SamplerAggregator*/, builder);
|
||||
registerAggregation(new AggregationSpec(TermsAggregationBuilder.NAME, TermsAggregationBuilder::new,
|
||||
TermsAggregationBuilder.PARSER)
|
||||
.addResultReader(StringTerms.NAME, StringTerms::new)
|
||||
.addResultReader(UnmappedTerms.NAME, UnmappedTerms::new)
|
||||
.addResultReader(LongTerms.NAME, LongTerms::new)
|
||||
.addResultReader(DoubleTerms.NAME, DoubleTerms::new)
|
||||
.setAggregatorRegistrar(TermsAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(TermsAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(RareTermsAggregationBuilder.NAME, RareTermsAggregationBuilder::new,
|
||||
RareTermsAggregationBuilder.PARSER)
|
||||
.addResultReader(StringRareTerms.NAME, StringRareTerms::new)
|
||||
.addResultReader(UnmappedRareTerms.NAME, UnmappedRareTerms::new)
|
||||
.addResultReader(LongRareTerms.NAME, LongRareTerms::new)
|
||||
.setAggregatorRegistrar(RareTermsAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(RareTermsAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(SignificantTermsAggregationBuilder.NAME, SignificantTermsAggregationBuilder::new,
|
||||
SignificantTermsAggregationBuilder::parse)
|
||||
.addResultReader(SignificantStringTerms.NAME, SignificantStringTerms::new)
|
||||
.addResultReader(SignificantLongTerms.NAME, SignificantLongTerms::new)
|
||||
.addResultReader(UnmappedSignificantTerms.NAME, UnmappedSignificantTerms::new)
|
||||
.setAggregatorRegistrar(SignificantTermsAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(SignificantTermsAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(SignificantTextAggregationBuilder.NAME, SignificantTextAggregationBuilder::new,
|
||||
SignificantTextAggregationBuilder::parse));
|
||||
SignificantTextAggregationBuilder::parse), builder);
|
||||
registerAggregation(new AggregationSpec(RangeAggregationBuilder.NAME, RangeAggregationBuilder::new,
|
||||
RangeAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalRange::new)
|
||||
.setAggregatorRegistrar(RangeAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(RangeAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(DateRangeAggregationBuilder.NAME, DateRangeAggregationBuilder::new,
|
||||
DateRangeAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalDateRange::new)
|
||||
.setAggregatorRegistrar(DateRangeAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(DateRangeAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(IpRangeAggregationBuilder.NAME, IpRangeAggregationBuilder::new,
|
||||
IpRangeAggregationBuilder.PARSER).addResultReader(InternalBinaryRange::new));
|
||||
IpRangeAggregationBuilder.PARSER).addResultReader(InternalBinaryRange::new), builder);
|
||||
registerAggregation(new AggregationSpec(HistogramAggregationBuilder.NAME, HistogramAggregationBuilder::new,
|
||||
HistogramAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalHistogram::new)
|
||||
.setAggregatorRegistrar(HistogramAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(HistogramAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(DateHistogramAggregationBuilder.NAME, DateHistogramAggregationBuilder::new,
|
||||
DateHistogramAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalDateHistogram::new)
|
||||
.setAggregatorRegistrar(DateHistogramAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(DateHistogramAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(AutoDateHistogramAggregationBuilder.NAME, AutoDateHistogramAggregationBuilder::new,
|
||||
AutoDateHistogramAggregationBuilder.PARSER).addResultReader(InternalAutoDateHistogram::new));
|
||||
AutoDateHistogramAggregationBuilder.PARSER).addResultReader(InternalAutoDateHistogram::new), builder);
|
||||
registerAggregation(new AggregationSpec(GeoDistanceAggregationBuilder.NAME, GeoDistanceAggregationBuilder::new,
|
||||
GeoDistanceAggregationBuilder::parse).addResultReader(InternalGeoDistance::new));
|
||||
GeoDistanceAggregationBuilder::parse).addResultReader(InternalGeoDistance::new), builder);
|
||||
registerAggregation(new AggregationSpec(GeoHashGridAggregationBuilder.NAME, GeoHashGridAggregationBuilder::new,
|
||||
GeoHashGridAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalGeoHashGrid::new)
|
||||
.setAggregatorRegistrar(GeoHashGridAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(GeoHashGridAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(GeoTileGridAggregationBuilder.NAME, GeoTileGridAggregationBuilder::new,
|
||||
GeoTileGridAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalGeoTileGrid::new)
|
||||
.setAggregatorRegistrar(GeoTileGridAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(GeoTileGridAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(NestedAggregationBuilder.NAME, NestedAggregationBuilder::new,
|
||||
NestedAggregationBuilder::parse).addResultReader(InternalNested::new));
|
||||
NestedAggregationBuilder::parse).addResultReader(InternalNested::new), builder);
|
||||
registerAggregation(new AggregationSpec(ReverseNestedAggregationBuilder.NAME, ReverseNestedAggregationBuilder::new,
|
||||
ReverseNestedAggregationBuilder::parse).addResultReader(InternalReverseNested::new));
|
||||
ReverseNestedAggregationBuilder::parse).addResultReader(InternalReverseNested::new), builder);
|
||||
registerAggregation(new AggregationSpec(TopHitsAggregationBuilder.NAME, TopHitsAggregationBuilder::new,
|
||||
TopHitsAggregationBuilder::parse).addResultReader(InternalTopHits::new));
|
||||
TopHitsAggregationBuilder::parse).addResultReader(InternalTopHits::new), builder);
|
||||
registerAggregation(new AggregationSpec(GeoBoundsAggregationBuilder.NAME, GeoBoundsAggregationBuilder::new,
|
||||
GeoBoundsAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalGeoBounds::new)
|
||||
.setAggregatorRegistrar(GeoBoundsAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(GeoBoundsAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(GeoCentroidAggregationBuilder.NAME, GeoCentroidAggregationBuilder::new,
|
||||
GeoCentroidAggregationBuilder.PARSER)
|
||||
.addResultReader(InternalGeoCentroid::new)
|
||||
.setAggregatorRegistrar(GeoCentroidAggregationBuilder::registerAggregators));
|
||||
.setAggregatorRegistrar(GeoCentroidAggregationBuilder::registerAggregators), builder);
|
||||
registerAggregation(new AggregationSpec(ScriptedMetricAggregationBuilder.NAME, ScriptedMetricAggregationBuilder::new,
|
||||
ScriptedMetricAggregationBuilder.PARSER).addResultReader(InternalScriptedMetric::new));
|
||||
ScriptedMetricAggregationBuilder.PARSER).addResultReader(InternalScriptedMetric::new), builder);
|
||||
registerAggregation((new AggregationSpec(CompositeAggregationBuilder.NAME, CompositeAggregationBuilder::new,
|
||||
CompositeAggregationBuilder.PARSER).addResultReader(InternalComposite::new)));
|
||||
registerFromPlugin(plugins, SearchPlugin::getAggregations, this::registerAggregation);
|
||||
CompositeAggregationBuilder.PARSER).addResultReader(InternalComposite::new)), builder);
|
||||
registerFromPlugin(plugins, SearchPlugin::getAggregations, (agg) -> this.registerAggregation(agg, builder));
|
||||
|
||||
// after aggs have been registered, see if there are any new VSTypes that need to be linked to core fields
|
||||
registerFromPlugin(plugins, SearchPlugin::getBareAggregatorRegistrar, this::registerBareAggregatorRegistrar);
|
||||
registerFromPlugin(plugins, SearchPlugin::getAggregationExtentions,
|
||||
(registrar) -> {if (registrar != null) {registrar.accept(builder);}});
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void registerAggregation(AggregationSpec spec) {
|
||||
private void registerAggregation(AggregationSpec spec, ValuesSourceRegistry.Builder builder) {
|
||||
if (false == transportClient) {
|
||||
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
|
||||
String name = (String) c;
|
||||
@ -514,15 +522,9 @@ public class SearchModule {
|
||||
Writeable.Reader<? extends InternalAggregation> internalReader = t.getValue();
|
||||
namedWriteables.add(new NamedWriteableRegistry.Entry(InternalAggregation.class, writeableName, internalReader));
|
||||
}
|
||||
Consumer<ValuesSourceRegistry> register = spec.getAggregatorRegistrar();
|
||||
Consumer<ValuesSourceRegistry.Builder> register = spec.getAggregatorRegistrar();
|
||||
if (register != null) {
|
||||
register.accept(this.valuesSourceRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerBareAggregatorRegistrar(Consumer<ValuesSourceRegistry> registrar) {
|
||||
if (registrar != null) {
|
||||
registrar.accept(this.valuesSourceRegistry);
|
||||
register.accept(builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,8 @@ public class GeoHashGridAggregationBuilder extends GeoGridAggregationBuilder {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
GeoHashGridAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
GeoHashGridAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,8 +92,8 @@ public class GeoHashGridAggregatorFactory extends ValuesSourceAggregatorFactory
|
||||
requiredSize, shardSize, searchContext, parent, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(GeoHashGridAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(GeoHashGridAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
(GeoGridAggregatorSupplier) (name, factories, valuesSource, precision, geoBoundingBox, requiredSize, shardSize,
|
||||
aggregationContext, parent, metadata) -> {
|
||||
CellIdSource cellIdSource = new CellIdSource((ValuesSource.GeoPoint) valuesSource, precision, geoBoundingBox,
|
||||
|
@ -52,8 +52,8 @@ public class GeoTileGridAggregationBuilder extends GeoGridAggregationBuilder {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
GeoTileGridAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
GeoTileGridAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -90,8 +90,8 @@ public class GeoTileGridAggregatorFactory extends ValuesSourceAggregatorFactory
|
||||
requiredSize, shardSize, searchContext, parent, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(GeoTileGridAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(GeoTileGridAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
(GeoGridAggregatorSupplier) (name, factories, valuesSource, precision, geoBoundingBox, requiredSize, shardSize,
|
||||
aggregationContext, parent, metadata) -> {
|
||||
CellIdSource cellIdSource = new CellIdSource((ValuesSource.GeoPoint) valuesSource, precision, geoBoundingBox,
|
||||
|
@ -37,7 +37,7 @@ import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType.Relation;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||
import org.elasticsearch.search.aggregations.InternalOrder;
|
||||
@ -117,8 +117,8 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
|
||||
Histogram.ORDER_FIELD);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
DateHistogramAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
DateHistogramAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private DateIntervalWrapper dateHistogramInterval = new DateIntervalWrapper();
|
||||
@ -134,7 +134,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
|
||||
}
|
||||
|
||||
protected DateHistogramAggregationBuilder(DateHistogramAggregationBuilder clone,
|
||||
Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.dateHistogramInterval = clone.dateHistogramInterval;
|
||||
this.offset = clone.offset;
|
||||
@ -145,7 +145,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new DateHistogramAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuil
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
final ZoneId tz = timeZone();
|
||||
final Rounding rounding = dateHistogramInterval.createRounding(tz, offset);
|
||||
final ZoneId rewrittenTimeZone = rewriteTimeZone(queryShardContext);
|
||||
|
@ -43,8 +43,8 @@ import java.util.Map;
|
||||
|
||||
public final class DateHistogramAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(DateHistogramAggregationBuilder.NAME,
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(DateHistogramAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.DATE, CoreValuesSourceType.NUMERIC, CoreValuesSourceType.BOOLEAN),
|
||||
(DateHistogramAggregationSupplier) (String name,
|
||||
AggregatorFactories factories,
|
||||
@ -62,7 +62,7 @@ public final class DateHistogramAggregatorFactory extends ValuesSourceAggregator
|
||||
factories, rounding, shardRounding, order, keyed, minDocCount, extendedBounds, (ValuesSource.Numeric) valuesSource,
|
||||
formatter, aggregationContext, parent, metadata));
|
||||
|
||||
valuesSourceRegistry.register(DateHistogramAggregationBuilder.NAME,
|
||||
builder.register(DateHistogramAggregationBuilder.NAME,
|
||||
CoreValuesSourceType.RANGE,
|
||||
(DateHistogramAggregationSupplier) (String name,
|
||||
AggregatorFactories factories,
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||
import org.elasticsearch.search.aggregations.InternalOrder;
|
||||
@ -79,8 +79,8 @@ public class HistogramAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
Histogram.ORDER_FIELD);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
HistogramAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
HistogramAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private double interval;
|
||||
@ -101,7 +101,9 @@ public class HistogramAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected HistogramAggregationBuilder(HistogramAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected HistogramAggregationBuilder(HistogramAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.interval = clone.interval;
|
||||
this.offset = clone.offset;
|
||||
@ -113,7 +115,7 @@ public class HistogramAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new HistogramAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -304,7 +306,7 @@ public class HistogramAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new HistogramAggregatorFactory(name, config, interval, offset, order, keyed, minDocCount, minBound, maxBound,
|
||||
queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
@ -52,9 +52,8 @@ public final class HistogramAggregatorFactory extends ValuesSourceAggregatorFact
|
||||
private final long minDocCount;
|
||||
private final double minBound, maxBound;
|
||||
|
||||
// TODO: Registration should happen on the actual aggregator classes, but I don't want to set up the whole dynamic loading thing yet
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(HistogramAggregationBuilder.NAME, CoreValuesSourceType.RANGE,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(HistogramAggregationBuilder.NAME, CoreValuesSourceType.RANGE,
|
||||
new HistogramAggregatorSupplier() {
|
||||
@Override
|
||||
public Aggregator build(String name, AggregatorFactories factories, double interval, double offset,
|
||||
@ -73,7 +72,7 @@ public final class HistogramAggregatorFactory extends ValuesSourceAggregatorFact
|
||||
}
|
||||
);
|
||||
|
||||
valuesSourceRegistry.register(HistogramAggregationBuilder.NAME,
|
||||
builder.register(HistogramAggregationBuilder.NAME,
|
||||
Collections.unmodifiableList(Arrays.asList(CoreValuesSourceType.NUMERIC,
|
||||
CoreValuesSourceType.DATE,
|
||||
CoreValuesSourceType.BOOLEAN)),
|
||||
|
@ -26,12 +26,13 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -46,11 +47,17 @@ public class MissingAggregationBuilder extends ValuesSourceAggregationBuilder<Mi
|
||||
ValuesSourceAggregationBuilder.declareFields(PARSER, true, true, false);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
MissingAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public MissingAggregationBuilder(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected MissingAggregationBuilder(MissingAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected MissingAggregationBuilder(MissingAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -60,7 +67,7 @@ public class MissingAggregationBuilder extends ValuesSourceAggregationBuilder<Mi
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new MissingAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -90,7 +97,7 @@ public class MissingAggregationBuilder extends ValuesSourceAggregationBuilder<Mi
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new MissingAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -23,16 +23,35 @@ import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.Aggregator;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
public class MissingAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(
|
||||
MissingAggregationBuilder.NAME,
|
||||
Arrays.asList(
|
||||
CoreValuesSourceType.NUMERIC,
|
||||
CoreValuesSourceType.BYTES,
|
||||
CoreValuesSourceType.GEOPOINT,
|
||||
CoreValuesSourceType.RANGE,
|
||||
CoreValuesSourceType.IP,
|
||||
CoreValuesSourceType.BOOLEAN,
|
||||
CoreValuesSourceType.DATE
|
||||
),
|
||||
(MissingAggregatorSupplier) MissingAggregator::new
|
||||
);
|
||||
}
|
||||
|
||||
public MissingAggregatorFactory(String name, ValuesSourceConfig config, QueryShardContext queryShardContext,
|
||||
AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder,
|
||||
Map<String, Object> metadata) throws IOException {
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.search.aggregations.bucket.missing;
|
||||
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.search.aggregations.Aggregator;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface MissingAggregatorSupplier extends AggregatorSupplier {
|
||||
|
||||
Aggregator build(String name,
|
||||
AggregatorFactories factories,
|
||||
@Nullable ValuesSource valuesSource,
|
||||
SearchContext aggregationContext,
|
||||
Aggregator parent,
|
||||
Map<String, Object> metadata) throws IOException;
|
||||
}
|
@ -47,8 +47,9 @@ public class AbstractRangeAggregatorFactory<R extends Range> extends ValuesSourc
|
||||
private final boolean keyed;
|
||||
private final String aggregationTypeName;
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry, String aggregationName) {
|
||||
valuesSourceRegistry.register(aggregationName,
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder,
|
||||
String aggregationName) {
|
||||
builder.register(aggregationName,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new RangeAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||
@ -58,20 +58,22 @@ public class DateRangeAggregationBuilder extends AbstractRangeBuilder<DateRangeA
|
||||
return RangeAggregator.Range.fromXContent(parser);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
AbstractRangeAggregatorFactory.registerAggregators(valuesSourceRegistry, NAME);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
AbstractRangeAggregatorFactory.registerAggregators(builder, NAME);
|
||||
}
|
||||
|
||||
public DateRangeAggregationBuilder(String name) {
|
||||
super(name, InternalDateRange.FACTORY);
|
||||
}
|
||||
|
||||
protected DateRangeAggregationBuilder(DateRangeAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected DateRangeAggregationBuilder(DateRangeAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new DateRangeAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -297,7 +299,8 @@ public class DateRangeAggregationBuilder extends AbstractRangeBuilder<DateRangeA
|
||||
|
||||
@Override
|
||||
protected DateRangeAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
// We need to call processRanges here so they are parsed and we know whether `now` has been used before we make
|
||||
// the decision of whether to cache the request
|
||||
RangeAggregator.Range[] ranges = processRanges(range -> {
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.bucket.range.RangeAggregator.Range;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||
@ -55,8 +55,8 @@ public class RangeAggregationBuilder extends AbstractRangeBuilder<RangeAggregati
|
||||
return Range.fromXContent(parser);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
AbstractRangeAggregatorFactory.registerAggregators(valuesSourceRegistry, NAME);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
AbstractRangeAggregatorFactory.registerAggregators(builder, NAME);
|
||||
}
|
||||
|
||||
public RangeAggregationBuilder(String name) {
|
||||
@ -70,12 +70,14 @@ public class RangeAggregationBuilder extends AbstractRangeBuilder<RangeAggregati
|
||||
super(in, InternalRange.FACTORY, Range::new);
|
||||
}
|
||||
|
||||
protected RangeAggregationBuilder(RangeAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected RangeAggregationBuilder(RangeAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new RangeAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -147,7 +149,8 @@ public class RangeAggregationBuilder extends AbstractRangeBuilder<RangeAggregati
|
||||
|
||||
@Override
|
||||
protected RangeAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
// We need to call processRanges here so they are parsed before we make the decision of whether to cache the request
|
||||
Range[] ranges = processRanges(range -> {
|
||||
DocValueFormat parser = config.format();
|
||||
|
@ -29,7 +29,7 @@ import org.elasticsearch.index.query.QueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryRewriteContext;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.JLHScore;
|
||||
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristic;
|
||||
@ -92,8 +92,8 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
|
||||
return PARSER.parse(parser, new SignificantTermsAggregationBuilder(aggregationName), null);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
SignificantTermsAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
SignificantTermsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private IncludeExclude includeExclude = null;
|
||||
@ -119,7 +119,7 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
|
||||
}
|
||||
|
||||
protected SignificantTermsAggregationBuilder(SignificantTermsAggregationBuilder clone,
|
||||
Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.bucketCountThresholds = new BucketCountThresholds(clone.bucketCountThresholds);
|
||||
this.executionHint = clone.executionHint;
|
||||
@ -134,7 +134,7 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SignificantTermsAggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected SignificantTermsAggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new SignificantTermsAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ public class SignificantTermsAggregationBuilder extends ValuesSourceAggregationB
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
SignificanceHeuristic executionHeuristic = this.significanceHeuristic.rewrite(queryShardContext);
|
||||
return new SignificantTermsAggregatorFactory(name, config, includeExclude, executionHint, filterBuilder,
|
||||
bucketCountThresholds, executionHeuristic, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
|
@ -77,12 +77,12 @@ public class SignificantTermsAggregatorFactory extends ValuesSourceAggregatorFac
|
||||
private final TermsAggregator.BucketCountThresholds bucketCountThresholds;
|
||||
private final SignificanceHeuristic significanceHeuristic;
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(SignificantTermsAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(SignificantTermsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP),
|
||||
SignificantTermsAggregatorFactory.bytesSupplier());
|
||||
|
||||
valuesSourceRegistry.register(SignificantTermsAggregationBuilder.NAME,
|
||||
builder.register(SignificantTermsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN, CoreValuesSourceType.NUMERIC),
|
||||
SignificantTermsAggregatorFactory.numericSupplier());
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||
@ -61,8 +61,8 @@ public class RareTermsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
PARSER.declareDouble(RareTermsAggregationBuilder::setPrecision, PRECISION);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
RareTermsAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
RareTermsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private IncludeExclude includeExclude = null;
|
||||
@ -73,7 +73,9 @@ public class RareTermsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
super(name);
|
||||
}
|
||||
|
||||
private RareTermsAggregationBuilder(RareTermsAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
private RareTermsAggregationBuilder(RareTermsAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.includeExclude = clone.includeExclude;
|
||||
}
|
||||
@ -84,7 +86,7 @@ public class RareTermsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new RareTermsAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -173,7 +175,7 @@ public class RareTermsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new RareTermsAggregatorFactory(name, config, includeExclude,
|
||||
queryShardContext, parent, subFactoriesBuilder, metadata, maxDocCount, precision);
|
||||
}
|
||||
|
@ -46,12 +46,12 @@ public class RareTermsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
private final int maxDocCount;
|
||||
private final double precision;
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(RareTermsAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(RareTermsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP),
|
||||
RareTermsAggregatorFactory.bytesSupplier());
|
||||
|
||||
valuesSourceRegistry.register(RareTermsAggregationBuilder.NAME,
|
||||
builder.register(RareTermsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN, CoreValuesSourceType.NUMERIC),
|
||||
RareTermsAggregatorFactory.numericSupplier());
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import org.elasticsearch.index.query.QueryRewriteContext;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.Aggregator.SubAggCollectionMode;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.BucketOrder;
|
||||
import org.elasticsearch.search.aggregations.InternalOrder;
|
||||
@ -93,8 +93,8 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Term
|
||||
IncludeExclude::parseExclude, IncludeExclude.EXCLUDE_FIELD, ObjectParser.ValueType.STRING_ARRAY);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
TermsAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
TermsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private BucketOrder order = BucketOrder.compound(BucketOrder.count(false)); // automatically adds tie-breaker key asc order
|
||||
@ -109,7 +109,9 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Term
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected TermsAggregationBuilder(TermsAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected TermsAggregationBuilder(TermsAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.order = clone.order;
|
||||
this.executionHint = clone.executionHint;
|
||||
@ -125,7 +127,7 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Term
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new TermsAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -344,7 +346,7 @@ public class TermsAggregationBuilder extends ValuesSourceAggregationBuilder<Term
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new TermsAggregatorFactory(name, config, order, includeExclude, executionHint, collectMode,
|
||||
bucketCountThresholds, showTermDocCountError, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
@ -61,13 +61,12 @@ public class TermsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
private final TermsAggregator.BucketCountThresholds bucketCountThresholds;
|
||||
private final boolean showTermDocCountError;
|
||||
|
||||
// TODO: Registration should happen on the actual aggregator classes
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(TermsAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(TermsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.BYTES, CoreValuesSourceType.IP),
|
||||
TermsAggregatorFactory.bytesSupplier());
|
||||
|
||||
valuesSourceRegistry.register(TermsAggregationBuilder.NAME,
|
||||
builder.register(TermsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN, CoreValuesSourceType.NUMERIC),
|
||||
TermsAggregatorFactory.numericSupplier());
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -45,15 +45,15 @@ public class AvgAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
ValuesSourceAggregationBuilder.declareFields(PARSER, true, true, false);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
AvgAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
AvgAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public AvgAggregationBuilder(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public AvgAggregationBuilder(AvgAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
public AvgAggregationBuilder(AvgAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class AvgAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new AvgAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -81,7 +81,8 @@ public class AvgAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
|
||||
@Override
|
||||
protected AvgAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new AvgAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,8 @@ class AvgAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
super(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(AvgAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(AvgAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new MetricAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -27,7 +27,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -56,8 +56,8 @@ public final class CardinalityAggregationBuilder
|
||||
PARSER.declareLong((b, v) -> {/*ignore*/}, REHASH);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
CardinalityAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
CardinalityAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private Long precisionThreshold = null;
|
||||
@ -66,7 +66,9 @@ public final class CardinalityAggregationBuilder
|
||||
super(name);
|
||||
}
|
||||
|
||||
public CardinalityAggregationBuilder(CardinalityAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
public CardinalityAggregationBuilder(CardinalityAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.precisionThreshold = clone.precisionThreshold;
|
||||
}
|
||||
@ -87,7 +89,7 @@ public final class CardinalityAggregationBuilder
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new CardinalityAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -129,7 +131,8 @@ public final class CardinalityAggregationBuilder
|
||||
|
||||
@Override
|
||||
protected CardinalityAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new CardinalityAggregatorFactory(name, config, precisionThreshold, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -48,8 +48,8 @@ class CardinalityAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
this.precisionThreshold = precisionThreshold;
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.registerAny(CardinalityAggregationBuilder.NAME, cardinalityAggregatorSupplier());
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.registerAny(CardinalityAggregationBuilder.NAME, cardinalityAggregatorSupplier());
|
||||
}
|
||||
|
||||
private static CardinalityAggregatorSupplier cardinalityAggregatorSupplier(){
|
||||
|
@ -25,12 +25,13 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -48,6 +49,10 @@ public class ExtendedStatsAggregationBuilder
|
||||
PARSER.declareDouble(ExtendedStatsAggregationBuilder::sigma, ExtendedStatsAggregator.SIGMA_FIELD);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
ExtendedStatsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private double sigma = 2.0;
|
||||
|
||||
public ExtendedStatsAggregationBuilder(String name) {
|
||||
@ -55,13 +60,13 @@ public class ExtendedStatsAggregationBuilder
|
||||
}
|
||||
|
||||
protected ExtendedStatsAggregationBuilder(ExtendedStatsAggregationBuilder clone,
|
||||
Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.sigma = clone.sigma;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new ExtendedStatsAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -97,7 +102,8 @@ public class ExtendedStatsAggregationBuilder
|
||||
|
||||
@Override
|
||||
protected ExtendedStatsAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new ExtendedStatsAggregatorFactory(name, config, sigma, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,16 @@ import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||
import org.elasticsearch.search.aggregations.Aggregator;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource.Numeric;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceConfig;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
class ExtendedStatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
@ -48,6 +51,12 @@ class ExtendedStatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
this.sigma = sigma;
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(ExtendedStatsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
(ExtendedStatsAggregatorProvider) ExtendedStatsAggregator::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Aggregator createUnmapped(SearchContext searchContext,
|
||||
Aggregator parent,
|
||||
|
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.elasticsearch.search.aggregations.metrics;
|
||||
|
||||
import org.elasticsearch.search.DocValueFormat;
|
||||
import org.elasticsearch.search.aggregations.Aggregator;
|
||||
import org.elasticsearch.search.aggregations.support.AggregatorSupplier;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
import org.elasticsearch.search.internal.SearchContext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExtendedStatsAggregatorProvider extends AggregatorSupplier {
|
||||
|
||||
Aggregator build(String name,
|
||||
ValuesSource.Numeric valuesSource,
|
||||
DocValueFormat formatter,
|
||||
SearchContext context,
|
||||
Aggregator parent,
|
||||
double sigma,
|
||||
Map<String, Object> metadata) throws IOException;
|
||||
}
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder;
|
||||
@ -47,8 +47,8 @@ public class GeoBoundsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
PARSER.declareBoolean(GeoBoundsAggregationBuilder::wrapLongitude, GeoBoundsAggregator.WRAP_LONGITUDE_FIELD);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
GeoBoundsAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
GeoBoundsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private boolean wrapLongitude = true;
|
||||
@ -57,13 +57,15 @@ public class GeoBoundsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected GeoBoundsAggregationBuilder(GeoBoundsAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected GeoBoundsAggregationBuilder(GeoBoundsAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
this.wrapLongitude = clone.wrapLongitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new GeoBoundsAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -107,7 +109,8 @@ public class GeoBoundsAggregationBuilder extends ValuesSourceAggregationBuilder<
|
||||
|
||||
@Override
|
||||
protected GeoBoundsAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new GeoBoundsAggregatorFactory(name, config, wrapLongitude, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,8 @@ class GeoBoundsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
return ((GeoBoundsAggregatorSupplier) aggregatorSupplier).build(name, searchContext, parent, valuesSource, wrapLongitude, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(GeoBoundsAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(GeoBoundsAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
(GeoBoundsAggregatorSupplier) (name, aggregationContext, parent, valuesSource, wrapLongitude, metadata)
|
||||
-> new GeoBoundsAggregator(name, aggregationContext, parent, (ValuesSource.GeoPoint) valuesSource,
|
||||
wrapLongitude, metadata));
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -47,15 +47,17 @@ public class GeoCentroidAggregationBuilder
|
||||
ValuesSourceAggregationBuilder.declareFields(PARSER, true, false, false);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
GeoCentroidAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
GeoCentroidAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public GeoCentroidAggregationBuilder(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected GeoCentroidAggregationBuilder(GeoCentroidAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected GeoCentroidAggregationBuilder(GeoCentroidAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -65,7 +67,7 @@ public class GeoCentroidAggregationBuilder
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new GeoCentroidAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -83,7 +85,8 @@ public class GeoCentroidAggregationBuilder
|
||||
|
||||
@Override
|
||||
protected GeoCentroidAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new GeoCentroidAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,8 @@ class GeoCentroidAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
return ((GeoCentroidAggregatorSupplier) aggregatorSupplier).build(name, searchContext, parent, valuesSource, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(GeoCentroidAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(GeoCentroidAggregationBuilder.NAME, CoreValuesSourceType.GEOPOINT,
|
||||
(GeoCentroidAggregatorSupplier) (name, context, parent, valuesSource, metadata) ->
|
||||
new GeoCentroidAggregator(name, context, parent, (ValuesSource.GeoPoint) valuesSource, metadata));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -45,15 +45,17 @@ public class MaxAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
ValuesSourceAggregationBuilder.declareFields(PARSER, true, true, false);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
MaxAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
MaxAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public MaxAggregationBuilder(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected MaxAggregationBuilder(MaxAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected MaxAggregationBuilder(MaxAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -63,7 +65,7 @@ public class MaxAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new MaxAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -81,7 +83,8 @@ public class MaxAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
|
||||
@Override
|
||||
protected MaxAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new MaxAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ import java.util.Map;
|
||||
|
||||
class MaxAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(MaxAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(MaxAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new MinMaxAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -54,8 +54,8 @@ public class MedianAbsoluteDeviationAggregationBuilder extends LeafOnly<ValuesSo
|
||||
PARSER.declareDouble(MedianAbsoluteDeviationAggregationBuilder::compression, COMPRESSION_FIELD);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
MedianAbsoluteDeviationAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
MedianAbsoluteDeviationAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
private double compression = 1000d;
|
||||
|
@ -52,8 +52,8 @@ public class MedianAbsoluteDeviationAggregatorFactory extends ValuesSourceAggreg
|
||||
this.compression = compression;
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(MedianAbsoluteDeviationAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(MedianAbsoluteDeviationAggregationBuilder.NAME,
|
||||
CoreValuesSourceType.NUMERIC,
|
||||
new MedianAbsoluteDeviationAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -49,17 +49,19 @@ public class MinAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected MinAggregationBuilder(MinAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected MinAggregationBuilder(MinAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new MinAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
MinAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
MinAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +83,8 @@ public class MinAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
|
||||
@Override
|
||||
protected MinAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new MinAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ import java.util.Map;
|
||||
|
||||
class MinAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(MinAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(MinAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new MinMaxAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||
@ -53,8 +53,8 @@ public class PercentileRanksAggregationBuilder extends AbstractPercentilesAggreg
|
||||
return PARSER.parse(parser, aggregationName);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
PercentileRanksAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
PercentileRanksAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public PercentileRanksAggregationBuilder(String name, double[] values) {
|
||||
@ -70,13 +70,13 @@ public class PercentileRanksAggregationBuilder extends AbstractPercentilesAggreg
|
||||
}
|
||||
|
||||
private PercentileRanksAggregationBuilder(PercentileRanksAggregationBuilder clone,
|
||||
Builder factoriesBuilder,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new PercentileRanksAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public class PercentileRanksAggregationBuilder extends AbstractPercentilesAggreg
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new PercentileRanksAggregatorFactory(name, config, values, configOrDefault(), keyed, queryShardContext,
|
||||
parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ class PercentileRanksAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
private final PercentilesConfig percentilesConfig;
|
||||
private final boolean keyed;
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(PercentileRanksAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(PercentileRanksAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new PercentilesAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ConstructingObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceAggregatorFactory;
|
||||
@ -59,8 +59,8 @@ public class PercentilesAggregationBuilder extends AbstractPercentilesAggregatio
|
||||
PERCENTS_FIELD);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
PercentilesAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
PercentilesAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public PercentilesAggregationBuilder(StreamInput in) throws IOException {
|
||||
@ -80,12 +80,12 @@ public class PercentilesAggregationBuilder extends AbstractPercentilesAggregatio
|
||||
}
|
||||
|
||||
protected PercentilesAggregationBuilder(PercentilesAggregationBuilder clone,
|
||||
Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new PercentilesAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class PercentilesAggregationBuilder extends AbstractPercentilesAggregatio
|
||||
protected ValuesSourceAggregatorFactory innerBuild(QueryShardContext queryShardContext,
|
||||
ValuesSourceConfig config,
|
||||
AggregatorFactory parent,
|
||||
Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new PercentilesAggregatorFactory(name, config, values, configOrDefault(), keyed,
|
||||
queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ class PercentilesAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
private final PercentilesConfig percentilesConfig;
|
||||
private final boolean keyed;
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(PercentilesAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(PercentilesAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new PercentilesAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -51,16 +51,16 @@ public class StatsAggregationBuilder extends ValuesSourceAggregationBuilder.Leaf
|
||||
}
|
||||
|
||||
protected StatsAggregationBuilder(StatsAggregationBuilder clone,
|
||||
Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
StatsAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
StatsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new StatsAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -83,7 +83,8 @@ public class StatsAggregationBuilder extends ValuesSourceAggregationBuilder.Leaf
|
||||
|
||||
@Override
|
||||
protected StatsAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new StatsAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ class StatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
super(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(StatsAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(StatsAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new MetricAggregatorSupplier() {
|
||||
@Override
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.common.xcontent.ObjectParser;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryShardContext;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories.Builder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactories;
|
||||
import org.elasticsearch.search.aggregations.AggregatorFactory;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSource;
|
||||
@ -45,20 +45,22 @@ public class SumAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
ValuesSourceAggregationBuilder.declareFields(PARSER, true, true, false);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
SumAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
SumAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public SumAggregationBuilder(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected SumAggregationBuilder(SumAggregationBuilder clone, Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected SumAggregationBuilder(SumAggregationBuilder clone,
|
||||
AggregatorFactories.Builder factoriesBuilder,
|
||||
Map<String, Object> metadata) {
|
||||
super(clone, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AggregationBuilder shallowCopy(Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) {
|
||||
return new SumAggregationBuilder(this, factoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
@ -81,7 +83,8 @@ public class SumAggregationBuilder extends ValuesSourceAggregationBuilder.LeafOn
|
||||
|
||||
@Override
|
||||
protected SumAggregatorFactory innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig config,
|
||||
AggregatorFactory parent, Builder subFactoriesBuilder) throws IOException {
|
||||
AggregatorFactory parent,
|
||||
AggregatorFactories.Builder subFactoriesBuilder) throws IOException {
|
||||
return new SumAggregatorFactory(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,9 @@ class SumAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
super(name, config, queryShardContext, parent, subFactoriesBuilder, metadata);
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(SumAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(SumAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, CoreValuesSourceType.DATE, CoreValuesSourceType.BOOLEAN),
|
||||
new MetricAggregatorSupplier() {
|
||||
@Override
|
||||
public Aggregator build(String name,
|
||||
|
@ -47,8 +47,8 @@ public class ValueCountAggregationBuilder extends ValuesSourceAggregationBuilder
|
||||
ValuesSourceAggregationBuilder.declareFields(PARSER, true, true, false);
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
ValueCountAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
ValueCountAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
public ValueCountAggregationBuilder(String name) {
|
||||
|
@ -36,8 +36,8 @@ import java.util.Map;
|
||||
|
||||
class ValueCountAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.registerAny(ValueCountAggregationBuilder.NAME,
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.registerAny(ValueCountAggregationBuilder.NAME,
|
||||
new ValueCountAggregatorSupplier() {
|
||||
@Override
|
||||
public Aggregator build(String name,
|
||||
|
@ -29,6 +29,7 @@ import org.elasticsearch.search.aggregations.AggregationExecutionException;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -41,78 +42,90 @@ import java.util.function.Predicate;
|
||||
*
|
||||
*/
|
||||
public class ValuesSourceRegistry {
|
||||
// Maps Aggregation names to (ValuesSourceType, Supplier) pairs, keyed by ValuesSourceType
|
||||
private Map<String, List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>>> aggregatorRegistry = new HashMap<>();
|
||||
public static class Builder {
|
||||
private final Map<String, List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>>> aggregatorRegistry = new HashMap<>();
|
||||
/**
|
||||
* Register a ValuesSource to Aggregator mapping.
|
||||
*
|
||||
* @param aggregationName The name of the family of aggregations, typically found via
|
||||
* {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param appliesTo A predicate which accepts the resolved {@link ValuesSourceType} and decides if the given aggregator can
|
||||
* be applied to that type.
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
*/
|
||||
public synchronized void register(String aggregationName, Predicate<ValuesSourceType> appliesTo,
|
||||
AggregatorSupplier aggregatorSupplier) {
|
||||
AbstractMap.SimpleEntry newSupplier = new AbstractMap.SimpleEntry<>(appliesTo, aggregatorSupplier);
|
||||
if (aggregatorRegistry.containsKey(aggregationName)) {
|
||||
aggregatorRegistry.get(aggregationName).add(newSupplier);
|
||||
} else {
|
||||
List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>> supplierList = new ArrayList<>();
|
||||
supplierList.add(newSupplier);
|
||||
aggregatorRegistry.put(aggregationName, supplierList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ValuesSource to Aggregator mapping.
|
||||
*
|
||||
* Threading behavior notes: This call is both synchronized and expensive. It copies the entire existing mapping structure each
|
||||
* time it is invoked. We expect that register will be called a small number of times during startup only (as plugins are being
|
||||
* registered) and we can tolerate the cost at that time. Once all plugins are registered, we should never need to call register
|
||||
* again. Comparatively, we expect to do many reads from the registry data structures, and those reads may be interleaved on
|
||||
* different worker threads. Thus we want to optimize the read case to be thread safe and fast, which the immutable
|
||||
* collections do well. Using immutable collections requires a copy on write mechanic, thus the somewhat non-intuitive
|
||||
* implementation of this method.
|
||||
* @param aggregationName The name of the family of aggregations, typically found via {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param appliesTo A predicate which accepts the resolved {@link ValuesSourceType} and decides if the given aggregator can be applied
|
||||
* to that type.
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
*/
|
||||
public synchronized void register(String aggregationName, Predicate<ValuesSourceType> appliesTo,
|
||||
AggregatorSupplier aggregatorSupplier) {
|
||||
AbstractMap.SimpleEntry newSupplier = new AbstractMap.SimpleEntry<>(appliesTo, aggregatorSupplier);
|
||||
if (aggregatorRegistry.containsKey(aggregationName)) {
|
||||
aggregatorRegistry.get(aggregationName).add(newSupplier);
|
||||
} else {
|
||||
List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>> supplierList = new ArrayList<>();
|
||||
supplierList.add(newSupplier);
|
||||
aggregatorRegistry.put(aggregationName, supplierList);
|
||||
/**
|
||||
* Register a ValuesSource to Aggregator mapping. This version provides a convenience method for mappings that only apply to a
|
||||
* single {@link ValuesSourceType}, to allow passing in the type and auto-wrapping it in a predicate
|
||||
*
|
||||
* @param aggregationName The name of the family of aggregations, typically found via
|
||||
* {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param valuesSourceType The ValuesSourceType this mapping applies to.
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
* from the aggregation standard set of parameters
|
||||
*/
|
||||
public void register(String aggregationName, ValuesSourceType valuesSourceType, AggregatorSupplier aggregatorSupplier) {
|
||||
register(aggregationName, (candidate) -> valuesSourceType.equals(candidate), aggregatorSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ValuesSource to Aggregator mapping. This version provides a convenience method for mappings that only apply to a
|
||||
* known list of {@link ValuesSourceType}, to allow passing in the type and auto-wrapping it in a predicate
|
||||
*
|
||||
* @param aggregationName The name of the family of aggregations, typically found via
|
||||
* {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param valuesSourceTypes The ValuesSourceTypes this mapping applies to.
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
* from the aggregation standard set of parameters
|
||||
*/
|
||||
public void register(String aggregationName, List<ValuesSourceType> valuesSourceTypes, AggregatorSupplier aggregatorSupplier) {
|
||||
register(aggregationName, (candidate) -> {
|
||||
for (ValuesSourceType valuesSourceType : valuesSourceTypes) {
|
||||
if (valuesSourceType.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, aggregatorSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an aggregator that applies to any values source type. This is a convenience method for aggregations that do not care at
|
||||
* all about the types of their inputs. Aggregations using this version of registration should not make any other registrations, as
|
||||
* the aggregator registered using this function will be applied in all cases.
|
||||
*
|
||||
* @param aggregationName The name of the family of aggregations, typically found via
|
||||
* {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
* from the aggregation standard set of parameters.
|
||||
*/
|
||||
public void registerAny(String aggregationName, AggregatorSupplier aggregatorSupplier) {
|
||||
register(aggregationName, (ignored) -> true, aggregatorSupplier);
|
||||
}
|
||||
|
||||
public ValuesSourceRegistry build() {
|
||||
return new ValuesSourceRegistry(aggregatorRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a ValuesSource to Aggregator mapping. This version provides a convenience method for mappings that only apply to a single
|
||||
* {@link ValuesSourceType}, to allow passing in the type and auto-wrapping it in a predicate
|
||||
* @param aggregationName The name of the family of aggregations, typically found via {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param valuesSourceType The ValuesSourceType this mapping applies to.
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
* from the aggregation standard set of parameters
|
||||
*/
|
||||
public void register(String aggregationName, ValuesSourceType valuesSourceType, AggregatorSupplier aggregatorSupplier) {
|
||||
register(aggregationName, (candidate) -> valuesSourceType.equals(candidate), aggregatorSupplier);
|
||||
}
|
||||
/** Maps Aggregation names to (ValuesSourceType, Supplier) pairs, keyed by ValuesSourceType */
|
||||
private Map<String, List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>>> aggregatorRegistry;
|
||||
|
||||
/**
|
||||
* Register a ValuesSource to Aggregator mapping. This version provides a convenience method for mappings that only apply to a known
|
||||
* list of {@link ValuesSourceType}, to allow passing in the type and auto-wrapping it in a predicate
|
||||
* @param aggregationName The name of the family of aggregations, typically found via {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param valuesSourceTypes The ValuesSourceTypes this mapping applies to.
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
* from the aggregation standard set of parameters
|
||||
*/
|
||||
public void register(String aggregationName, List<ValuesSourceType> valuesSourceTypes, AggregatorSupplier aggregatorSupplier) {
|
||||
register(aggregationName, (candidate) -> {
|
||||
for (ValuesSourceType valuesSourceType : valuesSourceTypes) {
|
||||
if (valuesSourceType.equals(candidate)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, aggregatorSupplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an aggregator that applies to any values source type. This is a convenience method for aggregations that do not care at all
|
||||
* about the types of their inputs. Aggregations using this version of registration should not make any other registrations, as the
|
||||
* aggregator registered using this function will be applied in all cases.
|
||||
*
|
||||
* @param aggregationName The name of the family of aggregations, typically found via {@link ValuesSourceAggregationBuilder#getType()}
|
||||
* @param aggregatorSupplier An Aggregation-specific specialization of AggregatorSupplier which will construct the mapped aggregator
|
||||
* from the aggregation standard set of parameters.
|
||||
*/
|
||||
public void registerAny(String aggregationName, AggregatorSupplier aggregatorSupplier) {
|
||||
register(aggregationName, (ignored) -> true, aggregatorSupplier);
|
||||
private ValuesSourceRegistry(Map<String, List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>>> aggregatorRegistry) {
|
||||
Map<String, List<Map.Entry<Predicate<ValuesSourceType>, AggregatorSupplier>>> tmp = new HashMap<>();
|
||||
aggregatorRegistry.forEach((key, value) -> tmp.put(key, Collections.unmodifiableList(value)));
|
||||
this.aggregatorRegistry = Collections.unmodifiableMap(tmp);
|
||||
}
|
||||
|
||||
private AggregatorSupplier findMatchingSuppier(ValuesSourceType valuesSourceType,
|
||||
|
@ -26,10 +26,24 @@ import java.time.ZoneId;
|
||||
import java.util.function.LongSupplier;
|
||||
|
||||
/**
|
||||
* ValuesSourceType wraps the creation of specific per-source instances each {@link ValuesSource} needs to provide. Every top-level
|
||||
* subclass of {@link ValuesSource} should have a corresponding implementation of this interface. In general, new data types seeking
|
||||
* aggregation support should create a top level {@link ValuesSource}, then implement this to return wrappers for the specific sources of
|
||||
* values.
|
||||
=======
|
||||
* {@link ValuesSourceType} represents a collection of fields that share a common set of operations, for example all numeric fields.
|
||||
* Aggregations declare their support for a given ValuesSourceType (via {@link ValuesSourceRegistry.Builder#register}),
|
||||
* and should then not need to care about the fields which use that ValuesSourceType.
|
||||
*
|
||||
* ValuesSourceTypes provide a set of methods to instantiate concrete {@link ValuesSource} instances, based on the actual source of the
|
||||
* data for the aggregations. In general, aggregations should not call these methods, but rather rely on {@link ValuesSourceConfig} to have
|
||||
* selected the correct implementation.
|
||||
*
|
||||
* ValuesSourceTypes should be stateless. We recommend that plugins define an enum for their ValuesSourceTypes, even if the plugin only
|
||||
* intends to define one ValuesSourceType. ValuesSourceTypes are not serialized as part of the aggregations framework.
|
||||
*
|
||||
* Prefer reusing an existing ValuesSourceType (ideally from {@link CoreValuesSourceType}) over creating a new type. There are some cases
|
||||
* where creating a new type is necessary however. In particular, consider a new ValuesSourceType if the field has custom encoding/decoding
|
||||
* requirements; if the field needs to expose additional information to the aggregation (e.g. {@link ValuesSource.Range#rangeType()}); or
|
||||
* if logically the type needs a more restricted use (e.g. even though dates are stored as numbers, it doesn't make sense to pass them to
|
||||
* a sum aggregation). When adding a new ValuesSourceType, new aggregators should be added and registered at the same time, to add support
|
||||
* for the new type to existing aggregations, as appropriate.
|
||||
*/
|
||||
public interface ValuesSourceType {
|
||||
/**
|
||||
|
@ -96,6 +96,7 @@ import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.indices.fielddata.cache.IndicesFieldDataCache;
|
||||
import org.elasticsearch.indices.mapper.MapperRegistry;
|
||||
import org.elasticsearch.mock.orig.Mockito;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.script.ScriptService;
|
||||
import org.elasticsearch.search.SearchModule;
|
||||
import org.elasticsearch.search.aggregations.MultiBucketConsumerService.MultiBucketConsumer;
|
||||
@ -113,7 +114,7 @@ import org.elasticsearch.search.lookup.SearchLookup;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.InternalAggregationTestCase;
|
||||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
@ -128,8 +129,8 @@ import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.elasticsearch.test.InternalAggregationTestCase.DEFAULT_MAX_BUCKETS;
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
@ -146,7 +147,7 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||
private static final String NESTEDFIELD_PREFIX = "nested_";
|
||||
private List<Releasable> releasables = new ArrayList<>();
|
||||
private static final String TYPE_NAME = "type";
|
||||
protected static ValuesSourceRegistry valuesSourceRegistry;
|
||||
protected ValuesSourceRegistry valuesSourceRegistry;
|
||||
|
||||
// A list of field types that should not be tested, or are not currently supported
|
||||
private static List<String> TYPE_TEST_BLACKLIST;
|
||||
@ -181,12 +182,20 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void initValuesSourceRegistry() {
|
||||
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
|
||||
// Make this @Before instead of @BeforeClass so it can call the non-static getSearchPlugins method
|
||||
@Before
|
||||
public void initValuesSourceRegistry() {
|
||||
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, getSearchPlugins());
|
||||
valuesSourceRegistry = searchModule.getValuesSourceRegistry();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test cases should override this if they have plugins that need to be loaded, e.g. the plugins their aggregators are in.
|
||||
*/
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected <A extends Aggregator> A createAggregator(AggregationBuilder aggregationBuilder,
|
||||
IndexSearcher indexSearcher,
|
||||
MappedFieldType... fieldTypes) throws IOException {
|
||||
|
@ -141,7 +141,7 @@ public class AnalyticsPlugin extends Plugin implements SearchPlugin, ActionPlugi
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Consumer<ValuesSourceRegistry>> getBareAggregatorRegistrar() {
|
||||
public List<Consumer<ValuesSourceRegistry.Builder>> getAggregationExtentions() {
|
||||
return Arrays.asList(AnalyticsPercentilesAggregatorFactory::registerPercentilesAggregator,
|
||||
AnalyticsPercentilesAggregatorFactory::registerPercentileRanksAggregator);
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ import org.elasticsearch.search.aggregations.support.ValuesSourceRegistry;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||
|
||||
public class AnalyticsPercentilesAggregatorFactory {
|
||||
public static void registerPercentilesAggregator(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(PercentilesAggregationBuilder.NAME,
|
||||
public static void registerPercentilesAggregator(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(PercentilesAggregationBuilder.NAME,
|
||||
AnalyticsValuesSourceType.HISTOGRAM,
|
||||
(PercentilesAggregatorSupplier) (name, valuesSource, context, parent, percents, percentilesConfig, keyed,
|
||||
formatter, metadata) -> {
|
||||
@ -37,8 +37,8 @@ public class AnalyticsPercentilesAggregatorFactory {
|
||||
});
|
||||
}
|
||||
|
||||
public static void registerPercentileRanksAggregator(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(PercentileRanksAggregationBuilder.NAME,
|
||||
public static void registerPercentileRanksAggregator(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(PercentileRanksAggregationBuilder.NAME,
|
||||
AnalyticsValuesSourceType.HISTOGRAM,
|
||||
(PercentilesAggregatorSupplier) (name, valuesSource, context, parent, percents, percentilesConfig, keyed,
|
||||
formatter, metadata) -> {
|
||||
|
@ -51,8 +51,8 @@ public class BoxplotAggregationBuilder extends ValuesSourceAggregationBuilder.Le
|
||||
this.compression = clone.compression;
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
BoxplotAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
BoxplotAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,8 +28,8 @@ public class BoxplotAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
|
||||
private final double compression;
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(BoxplotAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(BoxplotAggregationBuilder.NAME,
|
||||
Arrays.asList(CoreValuesSourceType.NUMERIC, AnalyticsValuesSourceType.HISTOGRAM),
|
||||
(BoxplotAggregatorSupplier) BoxplotAggregator::new);
|
||||
}
|
||||
|
@ -113,8 +113,8 @@ public class StringStatsAggregationBuilder extends ValuesSourceAggregationBuilde
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
StringStatsAggregatorFactory.registerAggregators(valuesSourceRegistry);
|
||||
public static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
StringStatsAggregatorFactory.registerAggregators(builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,8 +36,8 @@ class StringStatsAggregatorFactory extends ValuesSourceAggregatorFactory {
|
||||
this.showDistribution = showDistribution;
|
||||
}
|
||||
|
||||
static void registerAggregators(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(StringStatsAggregationBuilder.NAME,
|
||||
static void registerAggregators(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(StringStatsAggregationBuilder.NAME,
|
||||
CoreValuesSourceType.BYTES, new StringStatsAggregatorSupplier() {
|
||||
@Override
|
||||
public Aggregator build(String name,
|
||||
|
@ -23,6 +23,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.KeywordFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.NumberFieldMapper;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.script.MockScriptEngine;
|
||||
import org.elasticsearch.script.ScriptEngine;
|
||||
import org.elasticsearch.script.ScriptModule;
|
||||
@ -37,8 +38,8 @@ import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
|
||||
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -58,9 +59,9 @@ public class BoxplotAggregatorTests extends AggregatorTestCase {
|
||||
public static final String VALUE_SCRIPT = "_value";
|
||||
|
||||
|
||||
@BeforeClass()
|
||||
public static void registerBuilder() {
|
||||
BoxplotAggregationBuilder.registerAggregators(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Arrays.asList(new AnalyticsPlugin(Settings.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,9 @@ import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||
import org.elasticsearch.search.aggregations.metrics.InternalHDRPercentileRanks;
|
||||
@ -27,10 +29,9 @@ import org.elasticsearch.search.aggregations.metrics.PercentilesMethod;
|
||||
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.metrics.AnalyticsPercentilesAggregatorFactory;
|
||||
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -39,9 +40,9 @@ import java.util.List;
|
||||
|
||||
public class HDRPreAggregatedPercentileRanksAggregatorTests extends AggregatorTestCase {
|
||||
|
||||
@BeforeClass
|
||||
public static void registerBuilder() {
|
||||
AnalyticsPercentilesAggregatorFactory.registerPercentileRanksAggregator(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Arrays.asList(new AnalyticsPlugin(Settings.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,9 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.elasticsearch.common.CheckedConsumer;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.Aggregator;
|
||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||
@ -29,9 +31,8 @@ import org.elasticsearch.search.aggregations.metrics.PercentilesMethod;
|
||||
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.metrics.AnalyticsPercentilesAggregatorFactory;
|
||||
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -43,9 +44,9 @@ import static java.util.Collections.singleton;
|
||||
|
||||
public class HDRPreAggregatedPercentilesAggregatorTests extends AggregatorTestCase {
|
||||
|
||||
@BeforeClass
|
||||
public static void registerBuilder() {
|
||||
AnalyticsPercentilesAggregatorFactory.registerPercentilesAggregator(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Arrays.asList(new AnalyticsPlugin(Settings.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,9 @@ import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||
import org.elasticsearch.search.aggregations.metrics.InternalTDigestPercentileRanks;
|
||||
@ -28,10 +30,9 @@ import org.elasticsearch.search.aggregations.metrics.TDigestState;
|
||||
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.metrics.AnalyticsPercentilesAggregatorFactory;
|
||||
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -42,9 +43,9 @@ import java.util.List;
|
||||
|
||||
public class TDigestPreAggregatedPercentileRanksAggregatorTests extends AggregatorTestCase {
|
||||
|
||||
@BeforeClass
|
||||
public static void registerBuilder() {
|
||||
AnalyticsPercentilesAggregatorFactory.registerPercentileRanksAggregator(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Arrays.asList(new AnalyticsPlugin(Settings.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,9 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.elasticsearch.common.CheckedConsumer;
|
||||
import org.elasticsearch.common.io.stream.BytesStreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.Aggregator;
|
||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||
@ -30,9 +32,8 @@ import org.elasticsearch.search.aggregations.metrics.TDigestState;
|
||||
import org.elasticsearch.search.aggregations.support.AggregationInspectionHelper;
|
||||
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
|
||||
import org.elasticsearch.search.aggregations.support.ValuesSourceType;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.metrics.AnalyticsPercentilesAggregatorFactory;
|
||||
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
|
||||
import org.elasticsearch.xpack.analytics.aggregations.support.AnalyticsValuesSourceType;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -45,9 +46,9 @@ import static java.util.Collections.singleton;
|
||||
|
||||
public class TDigestPreAggregatedPercentilesAggregatorTests extends AggregatorTestCase {
|
||||
|
||||
@BeforeClass
|
||||
public static void registerBuilder() {
|
||||
AnalyticsPercentilesAggregatorFactory.registerPercentilesAggregator(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Arrays.asList(new AnalyticsPlugin(Settings.EMPTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,16 +18,18 @@ import org.apache.lucene.search.TermInSetQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.BytesRef;
|
||||
import org.elasticsearch.common.CheckedConsumer;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.mapper.NumberFieldMapper;
|
||||
import org.elasticsearch.index.mapper.TextFieldMapper;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator;
|
||||
import org.elasticsearch.search.aggregations.support.ValueType;
|
||||
import org.junit.BeforeClass;
|
||||
import org.elasticsearch.xpack.analytics.AnalyticsPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -38,10 +40,11 @@ import static java.util.Collections.singleton;
|
||||
|
||||
public class StringStatsAggregatorTests extends AggregatorTestCase {
|
||||
|
||||
@BeforeClass()
|
||||
public static void registerBuilder() {
|
||||
StringStatsAggregationBuilder.registerAggregators(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Arrays.asList(new AnalyticsPlugin(Settings.EMPTY));
|
||||
}
|
||||
|
||||
private static final String VALUE_SCRIPT_NAME = "value_script";
|
||||
private static final String FIELD_SCRIPT_NAME = "field_script";
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class SpatialPlugin extends GeoPlugin implements MapperPlugin, SearchPlug
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Consumer<ValuesSourceRegistry>> getBareAggregatorRegistrar() {
|
||||
public List<Consumer<ValuesSourceRegistry.Builder>> getAggregationExtentions() {
|
||||
return org.elasticsearch.common.collect.List.of(SpatialPlugin::registerGeoShapeBoundsAggregator);
|
||||
}
|
||||
|
||||
@ -66,8 +66,8 @@ public class SpatialPlugin extends GeoPlugin implements MapperPlugin, SearchPlug
|
||||
return Collections.singletonMap(CircleProcessor.TYPE, new CircleProcessor.Factory());
|
||||
}
|
||||
|
||||
public static void registerGeoShapeBoundsAggregator(ValuesSourceRegistry valuesSourceRegistry) {
|
||||
valuesSourceRegistry.register(GeoBoundsAggregationBuilder.NAME, GeoShapeValuesSourceType.instance(),
|
||||
public static void registerGeoShapeBoundsAggregator(ValuesSourceRegistry.Builder builder) {
|
||||
builder.register(GeoBoundsAggregationBuilder.NAME, GeoShapeValuesSourceType.instance(),
|
||||
(GeoBoundsAggregatorSupplier) (name, aggregationContext, parent, valuesSource, wrapLongitude, metadata)
|
||||
-> new GeoShapeBoundsAggregator(name, aggregationContext, parent, (GeoShapeValuesSource) valuesSource,
|
||||
wrapLongitude, metadata));
|
||||
|
@ -20,6 +20,7 @@ import org.elasticsearch.geometry.Geometry;
|
||||
import org.elasticsearch.geometry.MultiPoint;
|
||||
import org.elasticsearch.geometry.Point;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.plugins.SearchPlugin;
|
||||
import org.elasticsearch.search.aggregations.AggregationBuilder;
|
||||
import org.elasticsearch.search.aggregations.AggregatorTestCase;
|
||||
import org.elasticsearch.search.aggregations.metrics.GeoBoundsAggregationBuilder;
|
||||
@ -33,9 +34,9 @@ import org.elasticsearch.xpack.spatial.index.mapper.BinaryGeoShapeDocValuesField
|
||||
import org.elasticsearch.xpack.spatial.index.mapper.GeoShapeWithDocValuesFieldMapper;
|
||||
import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType;
|
||||
import org.elasticsearch.xpack.spatial.util.GeoTestUtils;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.closeTo;
|
||||
@ -45,9 +46,9 @@ import static org.hamcrest.Matchers.startsWith;
|
||||
public class GeoShapeBoundsAggregatorTests extends AggregatorTestCase {
|
||||
static final double GEOHASH_TOLERANCE = 1E-5D;
|
||||
|
||||
@BeforeClass()
|
||||
public static void registerAggregator() {
|
||||
SpatialPlugin.registerGeoShapeBoundsAggregator(valuesSourceRegistry);
|
||||
@Override
|
||||
protected List<SearchPlugin> getSearchPlugins() {
|
||||
return Collections.singletonList(new SpatialPlugin());
|
||||
}
|
||||
|
||||
public void testEmpty() throws Exception {
|
||||
|
Loading…
x
Reference in New Issue
Block a user