Flatten SearchService and clean up build-in registration
Relates to #12783
This commit is contained in:
parent
3b2f28fbe1
commit
6316718ae0
|
@ -47,7 +47,7 @@ import org.elasticsearch.monitor.MonitorService;
|
||||||
import org.elasticsearch.node.internal.InternalSettingsPreparer;
|
import org.elasticsearch.node.internal.InternalSettingsPreparer;
|
||||||
import org.elasticsearch.plugins.PluginsModule;
|
import org.elasticsearch.plugins.PluginsModule;
|
||||||
import org.elasticsearch.plugins.PluginsService;
|
import org.elasticsearch.plugins.PluginsService;
|
||||||
import org.elasticsearch.search.TransportSearchModule;
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.threadpool.ThreadPoolModule;
|
import org.elasticsearch.threadpool.ThreadPoolModule;
|
||||||
import org.elasticsearch.transport.TransportModule;
|
import org.elasticsearch.transport.TransportModule;
|
||||||
|
@ -138,8 +138,13 @@ public class TransportClient extends AbstractClient {
|
||||||
modules.add(new NetworkModule());
|
modules.add(new NetworkModule());
|
||||||
modules.add(new ClusterNameModule(this.settings));
|
modules.add(new ClusterNameModule(this.settings));
|
||||||
modules.add(new ThreadPoolModule(threadPool));
|
modules.add(new ThreadPoolModule(threadPool));
|
||||||
modules.add(new TransportSearchModule());
|
|
||||||
modules.add(new TransportModule(this.settings));
|
modules.add(new TransportModule(this.settings));
|
||||||
|
modules.add(new SearchModule(this.settings) {
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
});
|
||||||
modules.add(new ActionModule(true));
|
modules.add(new ActionModule(true));
|
||||||
modules.add(new ClientTransportModule());
|
modules.add(new ClientTransportModule());
|
||||||
modules.add(new CircuitBreakerModule(this.settings));
|
modules.add(new CircuitBreakerModule(this.settings));
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.index.query.functionscore;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionParser;
|
|
||||||
import org.elasticsearch.index.query.functionscore.factor.FactorParser;
|
|
||||||
import org.elasticsearch.index.query.functionscore.fieldvaluefactor.FieldValueFactorFunctionParser;
|
|
||||||
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParser;
|
|
||||||
import org.elasticsearch.index.query.functionscore.lin.LinearDecayFunctionParser;
|
|
||||||
import org.elasticsearch.index.query.functionscore.random.RandomScoreFunctionParser;
|
|
||||||
import org.elasticsearch.index.query.functionscore.script.ScriptScoreFunctionParser;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class FunctionScoreModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<Class<? extends ScoreFunctionParser>> parsers = Lists.newArrayList();
|
|
||||||
|
|
||||||
public FunctionScoreModule() {
|
|
||||||
registerParser(FactorParser.class);
|
|
||||||
registerParser(ScriptScoreFunctionParser.class);
|
|
||||||
registerParser(GaussDecayFunctionParser.class);
|
|
||||||
registerParser(LinearDecayFunctionParser.class);
|
|
||||||
registerParser(ExponentialDecayFunctionParser.class);
|
|
||||||
registerParser(RandomScoreFunctionParser.class);
|
|
||||||
registerParser(FieldValueFactorFunctionParser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerParser(Class<? extends ScoreFunctionParser> parser) {
|
|
||||||
parsers.add(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<ScoreFunctionParser> parserMapBinder = Multibinder.newSetBinder(binder(), ScoreFunctionParser.class);
|
|
||||||
for (Class<? extends ScoreFunctionParser> clazz : parsers) {
|
|
||||||
parserMapBinder.addBinding().to(clazz);
|
|
||||||
}
|
|
||||||
bind(ScoreFunctionParserMapper.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,28 +19,42 @@
|
||||||
|
|
||||||
package org.elasticsearch.index.query.functionscore;
|
package org.elasticsearch.index.query.functionscore;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import org.elasticsearch.common.Nullable;
|
||||||
|
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
import org.elasticsearch.index.query.QueryParseContext;
|
import org.elasticsearch.index.query.QueryParseContext;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
|
import org.elasticsearch.index.query.functionscore.exp.ExponentialDecayFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.factor.FactorParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.fieldvaluefactor.FieldValueFactorFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.gauss.GaussDecayFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.lin.LinearDecayFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.random.RandomScoreFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.script.ScriptScoreFunctionParser;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class ScoreFunctionParserMapper {
|
public class ScoreFunctionParserMapper {
|
||||||
|
|
||||||
protected ImmutableMap<String, ScoreFunctionParser> functionParsers;
|
protected Map<String, ScoreFunctionParser> functionParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ScoreFunctionParserMapper(Set<ScoreFunctionParser> parsers) {
|
public ScoreFunctionParserMapper(Set<ScoreFunctionParser> parsers) {
|
||||||
MapBuilder<String, ScoreFunctionParser> builder = MapBuilder.newMapBuilder();
|
Map<String, ScoreFunctionParser> map = new HashMap<>();
|
||||||
|
// build-in parsers
|
||||||
|
addParser(new FactorParser(), map);
|
||||||
|
addParser(new ScriptScoreFunctionParser(), map);
|
||||||
|
addParser(new GaussDecayFunctionParser(), map);
|
||||||
|
addParser(new LinearDecayFunctionParser(), map);
|
||||||
|
addParser(new ExponentialDecayFunctionParser(), map);
|
||||||
|
addParser(new RandomScoreFunctionParser(), map);
|
||||||
|
addParser(new FieldValueFactorFunctionParser(), map);
|
||||||
for (ScoreFunctionParser scoreFunctionParser : parsers) {
|
for (ScoreFunctionParser scoreFunctionParser : parsers) {
|
||||||
for (String name : scoreFunctionParser.getNames()) {
|
addParser(scoreFunctionParser, map);
|
||||||
builder.put(name, scoreFunctionParser);
|
|
||||||
}
|
}
|
||||||
}
|
this.functionParsers = Collections.unmodifiableMap(map);
|
||||||
this.functionParsers = builder.immutableMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) {
|
public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) {
|
||||||
|
@ -55,4 +69,10 @@ public class ScoreFunctionParserMapper {
|
||||||
return functionParsers.get(parserName);
|
return functionParsers.get(parserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addParser(ScoreFunctionParser scoreFunctionParser, Map<String, ScoreFunctionParser> map) {
|
||||||
|
for (String name : scoreFunctionParser.getNames()) {
|
||||||
|
map.put(name, scoreFunctionParser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,56 +19,370 @@
|
||||||
|
|
||||||
package org.elasticsearch.search;
|
package org.elasticsearch.search;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.Lists;
|
||||||
|
import org.elasticsearch.common.Classes;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.Module;
|
import org.elasticsearch.common.inject.binder.LinkedBindingBuilder;
|
||||||
import org.elasticsearch.common.inject.SpawnModules;
|
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionParserMapper;
|
||||||
import org.elasticsearch.index.search.morelikethis.MoreLikeThisFetchService;
|
import org.elasticsearch.index.search.morelikethis.MoreLikeThisFetchService;
|
||||||
import org.elasticsearch.search.action.SearchServiceTransportAction;
|
import org.elasticsearch.search.action.SearchServiceTransportAction;
|
||||||
import org.elasticsearch.search.aggregations.AggregationModule;
|
import org.elasticsearch.search.aggregations.*;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.children.ChildrenParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.children.InternalChildren;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.filter.FilterParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.filters.FiltersParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.filters.InternalFilters;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.global.GlobalParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.missing.InternalMissing;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.missing.MissingParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.nested.InternalNested;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.nested.InternalReverseNested;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.nested.NestedParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.InternalRange;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.RangeParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.date.DateRangeParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.date.InternalDateRange;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.geodistance.InternalGeoDistance;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.ipv4.InternalIPv4Range;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.range.ipv4.IpRangeParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.sampler.InternalSampler;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.sampler.UnmappedSampler;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.significant.SignificantLongTerms;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.significant.SignificantStringTerms;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.significant.SignificantTermsParser;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.significant.UnmappedSignificantTerms;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.*;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.terms.*;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.avg.AvgParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.avg.InternalAvg;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.cardinality.CardinalityParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.cardinality.InternalCardinality;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.max.InternalMax;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.max.MaxParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.min.InternalMin;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.min.MinParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanksParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentileRanks;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentiles;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentileRanks;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentiles;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.scripted.InternalScriptedMetric;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetricParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.stats.InternalStats;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.stats.StatsParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStatsParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExtendedStats;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.sum.InternalSum;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.sum.SumParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.tophits.InternalTopHits;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsParser;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount;
|
||||||
|
import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCountParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.movavg.models.*;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffParser;
|
||||||
|
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator;
|
||||||
import org.elasticsearch.search.controller.SearchPhaseController;
|
import org.elasticsearch.search.controller.SearchPhaseController;
|
||||||
import org.elasticsearch.search.dfs.DfsPhase;
|
import org.elasticsearch.search.dfs.DfsPhase;
|
||||||
import org.elasticsearch.search.fetch.FetchPhase;
|
import org.elasticsearch.search.fetch.FetchPhase;
|
||||||
import org.elasticsearch.search.fetch.FetchSubPhaseModule;
|
import org.elasticsearch.search.fetch.FetchSubPhase;
|
||||||
import org.elasticsearch.search.highlight.HighlightModule;
|
import org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase;
|
||||||
|
import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsFetchSubPhase;
|
||||||
|
import org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase;
|
||||||
|
import org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase;
|
||||||
|
import org.elasticsearch.search.fetch.script.ScriptFieldsFetchSubPhase;
|
||||||
|
import org.elasticsearch.search.fetch.source.FetchSourceSubPhase;
|
||||||
|
import org.elasticsearch.search.fetch.version.VersionFetchSubPhase;
|
||||||
|
import org.elasticsearch.search.highlight.*;
|
||||||
import org.elasticsearch.search.query.QueryPhase;
|
import org.elasticsearch.search.query.QueryPhase;
|
||||||
import org.elasticsearch.search.suggest.SuggestModule;
|
import org.elasticsearch.search.suggest.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SearchModule extends AbstractModule implements SpawnModules {
|
public class SearchModule extends AbstractModule {
|
||||||
|
|
||||||
|
public static final String SEARCH_SERVICE_IMPL = "search.service_impl";
|
||||||
|
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
|
private final List<Class<? extends Aggregator.Parser>> aggParsers = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends PipelineAggregator.Parser>> pipelineAggParsers = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends Highlighter>> highlighters = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends Suggester>> suggesters = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends ScoreFunctionParser>> functionScoreParsers = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends FetchSubPhase>> fetchSubPhases = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends SignificanceHeuristicParser>> heuristicParsers = Lists.newArrayList();
|
||||||
|
private final List<Class<? extends MovAvgModel.AbstractModelParser>> modelParsers = Lists.newArrayList();
|
||||||
|
|
||||||
public SearchModule(Settings settings) {
|
public SearchModule(Settings settings) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// TODO document public API
|
||||||
public Iterable<? extends Module> spawnModules() {
|
public void registerStream(SignificanceHeuristicStreams.Stream stream) {
|
||||||
return ImmutableList.of(
|
SignificanceHeuristicStreams.registerStream(stream);
|
||||||
new SearchServiceModule(settings),
|
|
||||||
new TransportSearchModule(),
|
|
||||||
new HighlightModule(),
|
|
||||||
new SuggestModule(),
|
|
||||||
new FunctionScoreModule(),
|
|
||||||
new AggregationModule(),
|
|
||||||
new FetchSubPhaseModule());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void registerStream(MovAvgModelStreams.Stream stream) {
|
||||||
|
MovAvgModelStreams.registerStream(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerHighlighter(Class<? extends Highlighter> clazz) {
|
||||||
|
highlighters.add(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerSuggester(Class<? extends Suggester> suggester) {
|
||||||
|
suggesters.add(suggester);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerFunctionScoreParser(Class<? extends ScoreFunctionParser> parser) {
|
||||||
|
functionScoreParsers.add(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerFetchSubPhase(Class<? extends FetchSubPhase> subPhase) {
|
||||||
|
fetchSubPhases.add(subPhase);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerHeuristicParser(Class<? extends SignificanceHeuristicParser> parser) {
|
||||||
|
heuristicParsers.add(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerModelParser(Class<? extends MovAvgModel.AbstractModelParser> parser) {
|
||||||
|
modelParsers.add(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enabling extending the get module by adding a custom aggregation parser.
|
||||||
|
*
|
||||||
|
* @param parser The parser for the custom aggregator.
|
||||||
|
*/
|
||||||
|
public void registerAggregatorParser(Class<? extends Aggregator.Parser> parser) {
|
||||||
|
aggParsers.add(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerPipelineParser(Class<? extends PipelineAggregator.Parser> parser) {
|
||||||
|
pipelineAggParsers.add(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
// configure search private classes...
|
||||||
bind(DfsPhase.class).asEagerSingleton();
|
bind(DfsPhase.class).asEagerSingleton();
|
||||||
bind(QueryPhase.class).asEagerSingleton();
|
bind(QueryPhase.class).asEagerSingleton();
|
||||||
bind(SearchPhaseController.class).asEagerSingleton();
|
bind(SearchPhaseController.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(FetchPhase.class).asEagerSingleton();
|
bind(FetchPhase.class).asEagerSingleton();
|
||||||
|
|
||||||
bind(SearchServiceTransportAction.class).asEagerSingleton();
|
bind(SearchServiceTransportAction.class).asEagerSingleton();
|
||||||
bind(MoreLikeThisFetchService.class).asEagerSingleton();
|
bind(MoreLikeThisFetchService.class).asEagerSingleton();
|
||||||
|
|
||||||
|
// search service -- testing only!
|
||||||
|
String impl = settings.get(SEARCH_SERVICE_IMPL);
|
||||||
|
if (impl == null) {
|
||||||
|
bind(SearchService.class).asEagerSingleton();
|
||||||
|
} else {
|
||||||
|
Class<? extends SearchService> implClass = Classes.loadClass(getClass().getClassLoader(), impl);
|
||||||
|
bind(SearchService.class).to(implClass).asEagerSingleton();
|
||||||
|
}
|
||||||
|
|
||||||
|
// aggs
|
||||||
|
Multibinder<Aggregator.Parser> multibinderAggParser = Multibinder.newSetBinder(binder(), Aggregator.Parser.class);
|
||||||
|
multibinderAggParser.addBinding().to(AvgParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(SumParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(MinParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(MaxParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(StatsParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(ExtendedStatsParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(ValueCountParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(PercentilesParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(PercentileRanksParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(CardinalityParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(GlobalParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(MissingParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(FilterParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(FiltersParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(SamplerParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(TermsParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(SignificantTermsParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(RangeParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(DateRangeParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(IpRangeParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(HistogramParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(DateHistogramParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(GeoDistanceParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(GeoHashGridParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(NestedParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(ReverseNestedParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(TopHitsParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(GeoBoundsParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(ScriptedMetricParser.class);
|
||||||
|
multibinderAggParser.addBinding().to(ChildrenParser.class);
|
||||||
|
for (Class<? extends Aggregator.Parser> parser : aggParsers) {
|
||||||
|
multibinderAggParser.addBinding().to(parser);
|
||||||
|
}
|
||||||
|
|
||||||
|
Multibinder<PipelineAggregator.Parser> multibinderPipelineAggParser = Multibinder.newSetBinder(binder(), PipelineAggregator.Parser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(DerivativeParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(MaxBucketParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(MinBucketParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(AvgBucketParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(SumBucketParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(MovAvgParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(CumulativeSumParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(BucketScriptParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(BucketSelectorParser.class);
|
||||||
|
multibinderPipelineAggParser.addBinding().to(SerialDiffParser.class);
|
||||||
|
for (Class<? extends PipelineAggregator.Parser> parser : pipelineAggParsers) {
|
||||||
|
multibinderPipelineAggParser.addBinding().to(parser);
|
||||||
|
}
|
||||||
|
bind(AggregatorParsers.class).asEagerSingleton();
|
||||||
|
bind(AggregationParseElement.class).asEagerSingleton();
|
||||||
|
bind(AggregationPhase.class).asEagerSingleton();
|
||||||
|
|
||||||
|
Multibinder<SignificanceHeuristicParser> heuristicParserMultibinder = Multibinder.newSetBinder(binder(), SignificanceHeuristicParser.class);
|
||||||
|
for (Class<? extends SignificanceHeuristicParser> clazz : heuristicParsers) {
|
||||||
|
heuristicParserMultibinder.addBinding().to(clazz);
|
||||||
|
}
|
||||||
|
bind(SignificanceHeuristicParserMapper.class);
|
||||||
|
|
||||||
|
Multibinder<MovAvgModel.AbstractModelParser> modelParserMultibinder = Multibinder.newSetBinder(binder(), MovAvgModel.AbstractModelParser.class);
|
||||||
|
for (Class<? extends MovAvgModel.AbstractModelParser> clazz : modelParsers) {
|
||||||
|
modelParserMultibinder.addBinding().to(clazz);
|
||||||
|
}
|
||||||
|
bind(MovAvgModelParserMapper.class);
|
||||||
|
|
||||||
|
// highlighters
|
||||||
|
Multibinder<Highlighter> multibinder = Multibinder.newSetBinder(binder(), Highlighter.class);
|
||||||
|
for (Class<? extends Highlighter> highlighter : highlighters) {
|
||||||
|
multibinder.addBinding().to(highlighter);
|
||||||
|
}
|
||||||
|
bind(Highlighters.class).asEagerSingleton();
|
||||||
|
|
||||||
|
// suggest
|
||||||
|
Multibinder<Suggester> suggesterMultibinder = Multibinder.newSetBinder(binder(), Suggester.class);
|
||||||
|
for (Class<? extends Suggester> clazz : suggesters) {
|
||||||
|
suggesterMultibinder.addBinding().to(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
bind(SuggestParseElement.class).asEagerSingleton();
|
||||||
|
bind(SuggestPhase.class).asEagerSingleton();
|
||||||
|
bind(Suggesters.class).asEagerSingleton();
|
||||||
|
|
||||||
|
// function score
|
||||||
|
Multibinder<ScoreFunctionParser> parserMapBinder = Multibinder.newSetBinder(binder(), ScoreFunctionParser.class);
|
||||||
|
for (Class<? extends ScoreFunctionParser> clazz : functionScoreParsers) {
|
||||||
|
parserMapBinder.addBinding().to(clazz);
|
||||||
|
}
|
||||||
|
bind(ScoreFunctionParserMapper.class);
|
||||||
|
|
||||||
|
// fetch sub phase
|
||||||
|
Multibinder<FetchSubPhase> fetchSubPhaseMultibinder = Multibinder.newSetBinder(binder(), FetchSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(ExplainFetchSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(FieldDataFieldsFetchSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(ScriptFieldsFetchSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(FetchSourceSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(VersionFetchSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(MatchedQueriesFetchSubPhase.class);
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(HighlightPhase.class);
|
||||||
|
for (Class<? extends FetchSubPhase> clazz : fetchSubPhases) {
|
||||||
|
fetchSubPhaseMultibinder.addBinding().to(clazz);
|
||||||
|
}
|
||||||
|
bind(InnerHitsFetchSubPhase.class).asEagerSingleton();
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
// calcs
|
||||||
|
InternalAvg.registerStreams();
|
||||||
|
InternalSum.registerStreams();
|
||||||
|
InternalMin.registerStreams();
|
||||||
|
InternalMax.registerStreams();
|
||||||
|
InternalStats.registerStreams();
|
||||||
|
InternalExtendedStats.registerStreams();
|
||||||
|
InternalValueCount.registerStreams();
|
||||||
|
InternalTDigestPercentiles.registerStreams();
|
||||||
|
InternalTDigestPercentileRanks.registerStreams();
|
||||||
|
InternalHDRPercentiles.registerStreams();
|
||||||
|
InternalHDRPercentileRanks.registerStreams();
|
||||||
|
InternalCardinality.registerStreams();
|
||||||
|
InternalScriptedMetric.registerStreams();
|
||||||
|
|
||||||
|
// buckets
|
||||||
|
InternalGlobal.registerStreams();
|
||||||
|
InternalFilter.registerStreams();
|
||||||
|
InternalFilters.registerStream();
|
||||||
|
InternalSampler.registerStreams();
|
||||||
|
UnmappedSampler.registerStreams();
|
||||||
|
InternalMissing.registerStreams();
|
||||||
|
StringTerms.registerStreams();
|
||||||
|
LongTerms.registerStreams();
|
||||||
|
SignificantStringTerms.registerStreams();
|
||||||
|
SignificantLongTerms.registerStreams();
|
||||||
|
UnmappedSignificantTerms.registerStreams();
|
||||||
|
InternalGeoHashGrid.registerStreams();
|
||||||
|
DoubleTerms.registerStreams();
|
||||||
|
UnmappedTerms.registerStreams();
|
||||||
|
InternalRange.registerStream();
|
||||||
|
InternalDateRange.registerStream();
|
||||||
|
InternalIPv4Range.registerStream();
|
||||||
|
InternalHistogram.registerStream();
|
||||||
|
InternalGeoDistance.registerStream();
|
||||||
|
InternalNested.registerStream();
|
||||||
|
InternalReverseNested.registerStream();
|
||||||
|
InternalTopHits.registerStreams();
|
||||||
|
InternalGeoBounds.registerStream();
|
||||||
|
InternalChildren.registerStream();
|
||||||
|
|
||||||
|
// Pipeline Aggregations
|
||||||
|
DerivativePipelineAggregator.registerStreams();
|
||||||
|
InternalDerivative.registerStreams();
|
||||||
|
InternalSimpleValue.registerStreams();
|
||||||
|
InternalBucketMetricValue.registerStreams();
|
||||||
|
MaxBucketPipelineAggregator.registerStreams();
|
||||||
|
MinBucketPipelineAggregator.registerStreams();
|
||||||
|
AvgBucketPipelineAggregator.registerStreams();
|
||||||
|
SumBucketPipelineAggregator.registerStreams();
|
||||||
|
MovAvgPipelineAggregator.registerStreams();
|
||||||
|
CumulativeSumPipelineAggregator.registerStreams();
|
||||||
|
BucketScriptPipelineAggregator.registerStreams();
|
||||||
|
BucketSelectorPipelineAggregator.registerStreams();
|
||||||
|
SerialDiffPipelineAggregator.registerStreams();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.Classes;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
|
|
||||||
public class SearchServiceModule extends AbstractModule {
|
|
||||||
|
|
||||||
public static final String IMPL = "search.service_impl";
|
|
||||||
|
|
||||||
private final Settings settings;
|
|
||||||
|
|
||||||
public SearchServiceModule(Settings settings) {
|
|
||||||
this.settings = settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
String impl = settings.get(IMPL);
|
|
||||||
if (impl == null) {
|
|
||||||
bind(SearchService.class).asEagerSingleton();
|
|
||||||
} else {
|
|
||||||
Class<? extends SearchService> implClass = Classes.loadClass(getClass().getClassLoader(), impl);
|
|
||||||
bind(SearchService.class).to(implClass).asEagerSingleton();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.Module;
|
|
||||||
import org.elasticsearch.common.inject.SpawnModules;
|
|
||||||
import org.elasticsearch.search.aggregations.TransportAggregationModule;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class TransportSearchModule extends AbstractModule implements SpawnModules {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<? extends Module> spawnModules() {
|
|
||||||
return ImmutableList.of(new TransportAggregationModule());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,156 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.Module;
|
|
||||||
import org.elasticsearch.common.inject.SpawnModules;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.children.ChildrenParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FilterParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.filters.FiltersParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.GeoHashGridParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.GlobalParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.HistogramParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.MissingParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.NestedParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.ReverseNestedParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.RangeParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.date.DateRangeParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.geodistance.GeoDistanceParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.ipv4.IpRangeParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.SamplerParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.significant.SignificantTermsParser;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificantTermsHeuristicModule;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.TermsParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.avg.AvgParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.cardinality.CardinalityParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.geobounds.GeoBoundsParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.max.MaxParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.min.MinParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentileRanksParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.percentiles.PercentilesParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.scripted.ScriptedMetricParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.stats.StatsParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.stats.extended.ExtendedStatsParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.sum.SumParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.tophits.TopHitsParser;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCountParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.PipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativeParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgParser;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.MovAvgModelModule;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffParser;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The main module for the get (binding all get components together)
|
|
||||||
*/
|
|
||||||
public class AggregationModule extends AbstractModule implements SpawnModules {
|
|
||||||
|
|
||||||
private List<Class<? extends Aggregator.Parser>> aggParsers = Lists.newArrayList();
|
|
||||||
private List<Class<? extends PipelineAggregator.Parser>> pipelineAggParsers = Lists.newArrayList();
|
|
||||||
|
|
||||||
public AggregationModule() {
|
|
||||||
aggParsers.add(AvgParser.class);
|
|
||||||
aggParsers.add(SumParser.class);
|
|
||||||
aggParsers.add(MinParser.class);
|
|
||||||
aggParsers.add(MaxParser.class);
|
|
||||||
aggParsers.add(StatsParser.class);
|
|
||||||
aggParsers.add(ExtendedStatsParser.class);
|
|
||||||
aggParsers.add(ValueCountParser.class);
|
|
||||||
aggParsers.add(PercentilesParser.class);
|
|
||||||
aggParsers.add(PercentileRanksParser.class);
|
|
||||||
aggParsers.add(CardinalityParser.class);
|
|
||||||
|
|
||||||
aggParsers.add(GlobalParser.class);
|
|
||||||
aggParsers.add(MissingParser.class);
|
|
||||||
aggParsers.add(FilterParser.class);
|
|
||||||
aggParsers.add(FiltersParser.class);
|
|
||||||
aggParsers.add(SamplerParser.class);
|
|
||||||
aggParsers.add(TermsParser.class);
|
|
||||||
aggParsers.add(SignificantTermsParser.class);
|
|
||||||
aggParsers.add(RangeParser.class);
|
|
||||||
aggParsers.add(DateRangeParser.class);
|
|
||||||
aggParsers.add(IpRangeParser.class);
|
|
||||||
aggParsers.add(HistogramParser.class);
|
|
||||||
aggParsers.add(DateHistogramParser.class);
|
|
||||||
aggParsers.add(GeoDistanceParser.class);
|
|
||||||
aggParsers.add(GeoHashGridParser.class);
|
|
||||||
aggParsers.add(NestedParser.class);
|
|
||||||
aggParsers.add(ReverseNestedParser.class);
|
|
||||||
aggParsers.add(TopHitsParser.class);
|
|
||||||
aggParsers.add(GeoBoundsParser.class);
|
|
||||||
aggParsers.add(ScriptedMetricParser.class);
|
|
||||||
aggParsers.add(ChildrenParser.class);
|
|
||||||
|
|
||||||
pipelineAggParsers.add(DerivativeParser.class);
|
|
||||||
pipelineAggParsers.add(MaxBucketParser.class);
|
|
||||||
pipelineAggParsers.add(MinBucketParser.class);
|
|
||||||
pipelineAggParsers.add(AvgBucketParser.class);
|
|
||||||
pipelineAggParsers.add(SumBucketParser.class);
|
|
||||||
pipelineAggParsers.add(MovAvgParser.class);
|
|
||||||
pipelineAggParsers.add(CumulativeSumParser.class);
|
|
||||||
pipelineAggParsers.add(BucketScriptParser.class);
|
|
||||||
pipelineAggParsers.add(BucketSelectorParser.class);
|
|
||||||
pipelineAggParsers.add(SerialDiffParser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enabling extending the get module by adding a custom aggregation parser.
|
|
||||||
*
|
|
||||||
* @param parser The parser for the custom aggregator.
|
|
||||||
*/
|
|
||||||
public void addAggregatorParser(Class<? extends Aggregator.Parser> parser) {
|
|
||||||
aggParsers.add(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<Aggregator.Parser> multibinderAggParser = Multibinder.newSetBinder(binder(), Aggregator.Parser.class);
|
|
||||||
for (Class<? extends Aggregator.Parser> parser : aggParsers) {
|
|
||||||
multibinderAggParser.addBinding().to(parser);
|
|
||||||
}
|
|
||||||
Multibinder<PipelineAggregator.Parser> multibinderPipelineAggParser = Multibinder.newSetBinder(binder(), PipelineAggregator.Parser.class);
|
|
||||||
for (Class<? extends PipelineAggregator.Parser> parser : pipelineAggParsers) {
|
|
||||||
multibinderPipelineAggParser.addBinding().to(parser);
|
|
||||||
}
|
|
||||||
bind(AggregatorParsers.class).asEagerSingleton();
|
|
||||||
bind(AggregationParseElement.class).asEagerSingleton();
|
|
||||||
bind(AggregationPhase.class).asEagerSingleton();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<? extends Module> spawnModules() {
|
|
||||||
return ImmutableList.of(new SignificantTermsHeuristicModule(), new MovAvgModelModule());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -50,7 +50,7 @@ public class AggregatorParsers {
|
||||||
*
|
*
|
||||||
* @param aggParsers
|
* @param aggParsers
|
||||||
* The available aggregator parsers (dynamically injected by the
|
* The available aggregator parsers (dynamically injected by the
|
||||||
* {@link org.elasticsearch.search.aggregations.AggregationModule}
|
* {@link org.elasticsearch.search.SearchModule}
|
||||||
* ).
|
* ).
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
|
|
|
@ -1,148 +0,0 @@
|
||||||
/*
|
|
||||||
* 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;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.Module;
|
|
||||||
import org.elasticsearch.common.inject.SpawnModules;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.children.InternalChildren;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.filters.InternalFilters;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.geogrid.InternalGeoHashGrid;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.global.InternalGlobal;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.histogram.InternalHistogram;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.missing.InternalMissing;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.InternalNested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.nested.InternalReverseNested;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.InternalRange;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.date.InternalDateRange;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.geodistance.InternalGeoDistance;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.range.ipv4.InternalIPv4Range;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.InternalSampler;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.sampler.UnmappedSampler;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.significant.SignificantLongTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.significant.SignificantStringTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.significant.UnmappedSignificantTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.TransportSignificantTermsHeuristicModule;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.DoubleTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.LongTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.StringTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.bucket.terms.UnmappedTerms;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.avg.InternalAvg;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.cardinality.InternalCardinality;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.geobounds.InternalGeoBounds;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.max.InternalMax;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.min.InternalMin;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentileRanks;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.percentiles.hdr.InternalHDRPercentiles;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentileRanks;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.percentiles.tdigest.InternalTDigestPercentiles;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.scripted.InternalScriptedMetric;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.stats.InternalStats;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.stats.extended.InternalExtendedStats;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.sum.InternalSum;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.tophits.InternalTopHits;
|
|
||||||
import org.elasticsearch.search.aggregations.metrics.valuecount.InternalValueCount;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.InternalBucketMetricValue;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.avg.AvgBucketPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.max.MaxBucketPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.min.MinBucketPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketmetrics.sum.SumBucketPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.bucketscript.BucketScriptPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.cumulativesum.CumulativeSumPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.derivative.DerivativePipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.derivative.InternalDerivative;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.having.BucketSelectorPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.movavg.MovAvgPipelineAggregator;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.movavg.models.TransportMovAvgModelModule;
|
|
||||||
import org.elasticsearch.search.aggregations.pipeline.serialdiff.SerialDiffPipelineAggregator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A module that registers all the transport streams for the addAggregation
|
|
||||||
*/
|
|
||||||
public class TransportAggregationModule extends AbstractModule implements SpawnModules {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
|
|
||||||
// calcs
|
|
||||||
InternalAvg.registerStreams();
|
|
||||||
InternalSum.registerStreams();
|
|
||||||
InternalMin.registerStreams();
|
|
||||||
InternalMax.registerStreams();
|
|
||||||
InternalStats.registerStreams();
|
|
||||||
InternalExtendedStats.registerStreams();
|
|
||||||
InternalValueCount.registerStreams();
|
|
||||||
InternalTDigestPercentiles.registerStreams();
|
|
||||||
InternalTDigestPercentileRanks.registerStreams();
|
|
||||||
InternalHDRPercentiles.registerStreams();
|
|
||||||
InternalHDRPercentileRanks.registerStreams();
|
|
||||||
InternalCardinality.registerStreams();
|
|
||||||
InternalScriptedMetric.registerStreams();
|
|
||||||
|
|
||||||
// buckets
|
|
||||||
InternalGlobal.registerStreams();
|
|
||||||
InternalFilter.registerStreams();
|
|
||||||
InternalFilters.registerStream();
|
|
||||||
InternalSampler.registerStreams();
|
|
||||||
UnmappedSampler.registerStreams();
|
|
||||||
InternalMissing.registerStreams();
|
|
||||||
StringTerms.registerStreams();
|
|
||||||
LongTerms.registerStreams();
|
|
||||||
SignificantStringTerms.registerStreams();
|
|
||||||
SignificantLongTerms.registerStreams();
|
|
||||||
UnmappedSignificantTerms.registerStreams();
|
|
||||||
InternalGeoHashGrid.registerStreams();
|
|
||||||
DoubleTerms.registerStreams();
|
|
||||||
UnmappedTerms.registerStreams();
|
|
||||||
InternalRange.registerStream();
|
|
||||||
InternalDateRange.registerStream();
|
|
||||||
InternalIPv4Range.registerStream();
|
|
||||||
InternalHistogram.registerStream();
|
|
||||||
InternalGeoDistance.registerStream();
|
|
||||||
InternalNested.registerStream();
|
|
||||||
InternalReverseNested.registerStream();
|
|
||||||
InternalTopHits.registerStreams();
|
|
||||||
InternalGeoBounds.registerStream();
|
|
||||||
InternalChildren.registerStream();
|
|
||||||
|
|
||||||
// Pipeline Aggregations
|
|
||||||
DerivativePipelineAggregator.registerStreams();
|
|
||||||
InternalDerivative.registerStreams();
|
|
||||||
InternalSimpleValue.registerStreams();
|
|
||||||
InternalBucketMetricValue.registerStreams();
|
|
||||||
MaxBucketPipelineAggregator.registerStreams();
|
|
||||||
MinBucketPipelineAggregator.registerStreams();
|
|
||||||
AvgBucketPipelineAggregator.registerStreams();
|
|
||||||
SumBucketPipelineAggregator.registerStreams();
|
|
||||||
MovAvgPipelineAggregator.registerStreams();
|
|
||||||
CumulativeSumPipelineAggregator.registerStreams();
|
|
||||||
BucketScriptPipelineAggregator.registerStreams();
|
|
||||||
BucketSelectorPipelineAggregator.registerStreams();
|
|
||||||
SerialDiffPipelineAggregator.registerStreams();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterable<? extends Module> spawnModules() {
|
|
||||||
return ImmutableList.of(new TransportSignificantTermsHeuristicModule(), new TransportMovAvgModelModule());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -124,7 +124,6 @@ public class ScriptHeuristic extends SignificanceHeuristic {
|
||||||
public static class ScriptHeuristicParser implements SignificanceHeuristicParser {
|
public static class ScriptHeuristicParser implements SignificanceHeuristicParser {
|
||||||
private final ScriptService scriptService;
|
private final ScriptService scriptService;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public ScriptHeuristicParser(ScriptService scriptService) {
|
public ScriptHeuristicParser(ScriptService scriptService) {
|
||||||
this.scriptService = scriptService;
|
this.scriptService = scriptService;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,28 +20,41 @@
|
||||||
|
|
||||||
package org.elasticsearch.search.aggregations.bucket.significant.heuristics;
|
package org.elasticsearch.search.aggregations.bucket.significant.heuristics;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class SignificanceHeuristicParserMapper {
|
public class SignificanceHeuristicParserMapper {
|
||||||
|
|
||||||
protected ImmutableMap<String, SignificanceHeuristicParser> significanceHeuristicParsers;
|
protected final Map<String, SignificanceHeuristicParser> significanceHeuristicParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SignificanceHeuristicParserMapper(Set<SignificanceHeuristicParser> parsers) {
|
public SignificanceHeuristicParserMapper(Set<SignificanceHeuristicParser> parsers, ScriptService scriptService) {
|
||||||
MapBuilder<String, SignificanceHeuristicParser> builder = MapBuilder.newMapBuilder();
|
Map<String, SignificanceHeuristicParser> map = new HashMap<>();
|
||||||
|
add(map, new JLHScore.JLHScoreParser());
|
||||||
|
add(map, new PercentageScore.PercentageScoreParser());
|
||||||
|
add(map, new MutualInformation.MutualInformationParser());
|
||||||
|
add(map, new ChiSquare.ChiSquareParser());
|
||||||
|
add(map, new GND.GNDParser());
|
||||||
|
add(map, new ScriptHeuristic.ScriptHeuristicParser(scriptService));
|
||||||
for (SignificanceHeuristicParser parser : parsers) {
|
for (SignificanceHeuristicParser parser : parsers) {
|
||||||
for (String name : parser.getNames()) {
|
add(map, parser);
|
||||||
builder.put(name, parser);
|
|
||||||
}
|
}
|
||||||
}
|
significanceHeuristicParsers = Collections.unmodifiableMap(map);
|
||||||
significanceHeuristicParsers = builder.immutableMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignificanceHeuristicParser get(String parserName) {
|
public SignificanceHeuristicParser get(String parserName) {
|
||||||
return significanceHeuristicParsers.get(parserName);
|
return significanceHeuristicParsers.get(parserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void add(Map<String, SignificanceHeuristicParser> map, SignificanceHeuristicParser parser) {
|
||||||
|
for (String type : parser.getNames()) {
|
||||||
|
map.put(type, parser);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.search.aggregations.bucket.significant.heuristics;
|
package org.elasticsearch.search.aggregations.bucket.significant.heuristics;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import org.elasticsearch.common.collect.CopyOnWriteHashMap;
|
||||||
import org.elasticsearch.Version;
|
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry for all significance heuristics. This is needed for reading them from a stream without knowing which
|
* A registry for all significance heuristics. This is needed for reading them from a stream without knowing which
|
||||||
|
@ -31,7 +31,18 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class SignificanceHeuristicStreams {
|
public class SignificanceHeuristicStreams {
|
||||||
|
|
||||||
private static ImmutableMap<String, Stream> STREAMS = ImmutableMap.of();
|
private static Map<String, Stream> STREAMS = Collections.EMPTY_MAP;
|
||||||
|
|
||||||
|
static {
|
||||||
|
HashMap<String, Stream> map = new HashMap<>();
|
||||||
|
map.put(JLHScore.STREAM.getName(), JLHScore.STREAM);
|
||||||
|
map.put(PercentageScore.STREAM.getName(), PercentageScore.STREAM);
|
||||||
|
map.put(MutualInformation.STREAM.getName(), MutualInformation.STREAM);
|
||||||
|
map.put(GND.STREAM.getName(), GND.STREAM);
|
||||||
|
map.put(ChiSquare.STREAM.getName(), ChiSquare.STREAM);
|
||||||
|
map.put(ScriptHeuristic.STREAM.getName(), ScriptHeuristic.STREAM);
|
||||||
|
STREAMS = Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
public static SignificanceHeuristic read(StreamInput in) throws IOException {
|
public static SignificanceHeuristic read(StreamInput in) throws IOException {
|
||||||
return stream(in.readString()).readResult(in);
|
return stream(in.readString()).readResult(in);
|
||||||
|
@ -51,14 +62,12 @@ public class SignificanceHeuristicStreams {
|
||||||
* Registers the given stream and associate it with the given types.
|
* Registers the given stream and associate it with the given types.
|
||||||
*
|
*
|
||||||
* @param stream The stream to register
|
* @param stream The stream to register
|
||||||
* @param names The names associated with the streams
|
|
||||||
*/
|
*/
|
||||||
public static synchronized void registerStream(Stream stream, String... names) {
|
public static synchronized void registerStream(Stream stream) {
|
||||||
MapBuilder<String, Stream> uStreams = MapBuilder.newMapBuilder(STREAMS);
|
HashMap<String, Stream> map = new HashMap<>();
|
||||||
for (String name : names) {
|
map.putAll(STREAMS);
|
||||||
uStreams.put(name, stream);
|
map.put(stream.getName(), stream);
|
||||||
}
|
STREAMS = Collections.unmodifiableMap(map);
|
||||||
STREAMS = uStreams.immutableMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +76,7 @@ public class SignificanceHeuristicStreams {
|
||||||
* @param name The given name
|
* @param name The given name
|
||||||
* @return The associated stream
|
* @return The associated stream
|
||||||
*/
|
*/
|
||||||
public static Stream stream(String name) {
|
public static synchronized Stream stream(String name) {
|
||||||
return STREAMS.get(name);
|
return STREAMS.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.significant.heuristics;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class SignificantTermsHeuristicModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<Class<? extends SignificanceHeuristicParser>> parsers = Lists.newArrayList();
|
|
||||||
|
|
||||||
public SignificantTermsHeuristicModule() {
|
|
||||||
|
|
||||||
registerParser(JLHScore.JLHScoreParser.class);
|
|
||||||
registerParser(PercentageScore.PercentageScoreParser.class);
|
|
||||||
registerParser(MutualInformation.MutualInformationParser.class);
|
|
||||||
registerParser(GND.GNDParser.class);
|
|
||||||
registerParser(ChiSquare.ChiSquareParser.class);
|
|
||||||
registerParser(ScriptHeuristic.ScriptHeuristicParser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerParser(Class<? extends SignificanceHeuristicParser> parser) {
|
|
||||||
parsers.add(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<SignificanceHeuristicParser> parserMapBinder = Multibinder.newSetBinder(binder(), SignificanceHeuristicParser.class);
|
|
||||||
for (Class<? extends SignificanceHeuristicParser> clazz : parsers) {
|
|
||||||
parserMapBinder.addBinding().to(clazz);
|
|
||||||
}
|
|
||||||
bind(SignificanceHeuristicParserMapper.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.significant.heuristics;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class TransportSignificantTermsHeuristicModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<SignificanceHeuristicStreams.Stream> streams = Lists.newArrayList();
|
|
||||||
|
|
||||||
public TransportSignificantTermsHeuristicModule() {
|
|
||||||
registerStream(JLHScore.STREAM);
|
|
||||||
registerStream(PercentageScore.STREAM);
|
|
||||||
registerStream(MutualInformation.STREAM);
|
|
||||||
registerStream(GND.STREAM);
|
|
||||||
registerStream(ChiSquare.STREAM);
|
|
||||||
registerStream(ScriptHeuristic.STREAM);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerStream(SignificanceHeuristicStreams.Stream stream) {
|
|
||||||
streams.add(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
for (SignificanceHeuristicStreams.Stream stream : streams) {
|
|
||||||
SignificanceHeuristicStreams.registerStream(stream, stream.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.pipeline.movavg.models;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the various model parsers
|
|
||||||
*/
|
|
||||||
public class MovAvgModelModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<Class<? extends MovAvgModel.AbstractModelParser>> parsers = Lists.newArrayList();
|
|
||||||
|
|
||||||
public MovAvgModelModule() {
|
|
||||||
registerParser(SimpleModel.SimpleModelParser.class);
|
|
||||||
registerParser(LinearModel.LinearModelParser.class);
|
|
||||||
registerParser(EwmaModel.SingleExpModelParser.class);
|
|
||||||
registerParser(HoltLinearModel.DoubleExpModelParser.class);
|
|
||||||
registerParser(HoltWintersModel.HoltWintersModelParser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerParser(Class<? extends MovAvgModel.AbstractModelParser> parser) {
|
|
||||||
parsers.add(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<MovAvgModel.AbstractModelParser> parserMapBinder = Multibinder.newSetBinder(binder(), MovAvgModel.AbstractModelParser.class);
|
|
||||||
for (Class<? extends MovAvgModel.AbstractModelParser> clazz : parsers) {
|
|
||||||
parserMapBinder.addBinding().to(clazz);
|
|
||||||
}
|
|
||||||
bind(MovAvgModelParserMapper.class);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -19,12 +19,12 @@
|
||||||
|
|
||||||
package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,15 +32,20 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class MovAvgModelParserMapper {
|
public class MovAvgModelParserMapper {
|
||||||
|
|
||||||
protected ImmutableMap<String, MovAvgModel.AbstractModelParser> movAvgParsers;
|
protected Map<String, MovAvgModel.AbstractModelParser> movAvgParsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public MovAvgModelParserMapper(Set<MovAvgModel.AbstractModelParser> parsers) {
|
public MovAvgModelParserMapper(Set<MovAvgModel.AbstractModelParser> parsers) {
|
||||||
MapBuilder<String, MovAvgModel.AbstractModelParser> builder = MapBuilder.newMapBuilder();
|
Map<String, MovAvgModel.AbstractModelParser> map = new HashMap<>();
|
||||||
|
add(map, new SimpleModel.SimpleModelParser());
|
||||||
|
add(map, new LinearModel.LinearModelParser());
|
||||||
|
add(map, new EwmaModel.SingleExpModelParser());
|
||||||
|
add(map, new HoltLinearModel.DoubleExpModelParser());
|
||||||
|
add(map, new HoltWintersModel.HoltWintersModelParser());
|
||||||
for (MovAvgModel.AbstractModelParser parser : parsers) {
|
for (MovAvgModel.AbstractModelParser parser : parsers) {
|
||||||
builder.put(parser.getName(), parser);
|
add(map, parser);
|
||||||
}
|
}
|
||||||
movAvgParsers = builder.immutableMap();
|
movAvgParsers = Collections.unmodifiableMap(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable
|
public @Nullable
|
||||||
|
@ -48,7 +53,11 @@ public class MovAvgModelParserMapper {
|
||||||
return movAvgParsers.get(parserName);
|
return movAvgParsers.get(parserName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableSet<String> getAllNames() {
|
public Set<String> getAllNames() {
|
||||||
return movAvgParsers.keySet();
|
return movAvgParsers.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void add(Map<String, MovAvgModel.AbstractModelParser> map, MovAvgModel.AbstractModelParser parser) {
|
||||||
|
map.put(parser.getName(), parser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,12 @@
|
||||||
|
|
||||||
package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
package org.elasticsearch.search.aggregations.pipeline.movavg.models;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registry for all moving average models. This is needed for reading them from a stream without knowing which
|
* A registry for all moving average models. This is needed for reading them from a stream without knowing which
|
||||||
|
@ -31,7 +32,17 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class MovAvgModelStreams {
|
public class MovAvgModelStreams {
|
||||||
|
|
||||||
private static ImmutableMap<String, Stream> STREAMS = ImmutableMap.of();
|
private static Map<String, Stream> STREAMS = Collections.EMPTY_MAP;
|
||||||
|
|
||||||
|
static {
|
||||||
|
HashMap<String, Stream> map = new HashMap<>();
|
||||||
|
map.put(SimpleModel.STREAM.getName(), SimpleModel.STREAM);
|
||||||
|
map.put(LinearModel.STREAM.getName(), LinearModel.STREAM);
|
||||||
|
map.put(EwmaModel.STREAM.getName(), EwmaModel.STREAM);
|
||||||
|
map.put(HoltLinearModel.STREAM.getName(), HoltLinearModel.STREAM);
|
||||||
|
map.put(HoltWintersModel.STREAM.getName(), HoltWintersModel.STREAM);
|
||||||
|
STREAMS = Collections.unmodifiableMap(map);
|
||||||
|
}
|
||||||
|
|
||||||
public static MovAvgModel read(StreamInput in) throws IOException {
|
public static MovAvgModel read(StreamInput in) throws IOException {
|
||||||
return stream(in.readString()).readResult(in);
|
return stream(in.readString()).readResult(in);
|
||||||
|
@ -40,7 +51,7 @@ public class MovAvgModelStreams {
|
||||||
/**
|
/**
|
||||||
* A stream that knows how to read an heuristic from the input.
|
* A stream that knows how to read an heuristic from the input.
|
||||||
*/
|
*/
|
||||||
public static interface Stream {
|
public interface Stream {
|
||||||
|
|
||||||
MovAvgModel readResult(StreamInput in) throws IOException;
|
MovAvgModel readResult(StreamInput in) throws IOException;
|
||||||
|
|
||||||
|
@ -51,14 +62,12 @@ public class MovAvgModelStreams {
|
||||||
* Registers the given stream and associate it with the given types.
|
* Registers the given stream and associate it with the given types.
|
||||||
*
|
*
|
||||||
* @param stream The stream to register
|
* @param stream The stream to register
|
||||||
* @param names The names associated with the streams
|
|
||||||
*/
|
*/
|
||||||
public static synchronized void registerStream(Stream stream, String... names) {
|
public static synchronized void registerStream(Stream stream) {
|
||||||
MapBuilder<String, Stream> uStreams = MapBuilder.newMapBuilder(STREAMS);
|
HashMap<String, Stream> map = new HashMap<>();
|
||||||
for (String name : names) {
|
map.putAll(STREAMS);
|
||||||
uStreams.put(name, stream);
|
map.put(stream.getName(), stream);
|
||||||
}
|
STREAMS = Collections.unmodifiableMap(map);
|
||||||
STREAMS = uStreams.immutableMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +76,7 @@ public class MovAvgModelStreams {
|
||||||
* @param name The given name
|
* @param name The given name
|
||||||
* @return The associated stream
|
* @return The associated stream
|
||||||
*/
|
*/
|
||||||
public static Stream stream(String name) {
|
public static synchronized Stream stream(String name) {
|
||||||
return STREAMS.get(name);
|
return STREAMS.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.pipeline.movavg.models;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the transport streams so that models can be serialized/deserialized from the stream
|
|
||||||
*/
|
|
||||||
public class TransportMovAvgModelModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<MovAvgModelStreams.Stream> streams = Lists.newArrayList();
|
|
||||||
|
|
||||||
public TransportMovAvgModelModule() {
|
|
||||||
registerStream(SimpleModel.STREAM);
|
|
||||||
registerStream(LinearModel.STREAM);
|
|
||||||
registerStream(EwmaModel.STREAM);
|
|
||||||
registerStream(HoltLinearModel.STREAM);
|
|
||||||
registerStream(HoltWintersModel.STREAM);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerStream(MovAvgModelStreams.Stream stream) {
|
|
||||||
streams.add(stream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
for (MovAvgModelStreams.Stream stream : streams) {
|
|
||||||
MovAvgModelStreams.registerStream(stream, stream.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.fetch;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
import org.elasticsearch.search.fetch.explain.ExplainFetchSubPhase;
|
|
||||||
import org.elasticsearch.search.fetch.fielddata.FieldDataFieldsFetchSubPhase;
|
|
||||||
import org.elasticsearch.search.fetch.innerhits.InnerHitsFetchSubPhase;
|
|
||||||
import org.elasticsearch.search.fetch.matchedqueries.MatchedQueriesFetchSubPhase;
|
|
||||||
import org.elasticsearch.search.fetch.script.ScriptFieldsFetchSubPhase;
|
|
||||||
import org.elasticsearch.search.fetch.source.FetchSourceSubPhase;
|
|
||||||
import org.elasticsearch.search.fetch.version.VersionFetchSubPhase;
|
|
||||||
import org.elasticsearch.search.highlight.HighlightPhase;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module for registering fetch sub phases. Fetch phases are executed when the document is finally
|
|
||||||
* retrieved from the shard. To implement a new fetch phase one needs to implement the following classes and interfaces
|
|
||||||
* <p/>
|
|
||||||
* <ul>
|
|
||||||
* <li> {@link FetchSubPhaseParseElement} </li>
|
|
||||||
* <li> {@link FetchSubPhase} </li>
|
|
||||||
* <li> {@link FetchSubPhaseContext} </li>
|
|
||||||
* </ul>
|
|
||||||
* <p/>
|
|
||||||
* The FetchSubPhase must then be registered with this module with {@link FetchSubPhaseModule#registerFetchSubPhase(Class<? extends FetchSubPhase>)}.
|
|
||||||
* See {@link FieldDataFieldsFetchSubPhase} for an example.
|
|
||||||
*/
|
|
||||||
public class FetchSubPhaseModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<Class<? extends FetchSubPhase>> fetchSubPhases = Lists.newArrayList();
|
|
||||||
|
|
||||||
public FetchSubPhaseModule() {
|
|
||||||
registerFetchSubPhase(ExplainFetchSubPhase.class);
|
|
||||||
registerFetchSubPhase(FieldDataFieldsFetchSubPhase.class);
|
|
||||||
registerFetchSubPhase(ScriptFieldsFetchSubPhase.class);
|
|
||||||
registerFetchSubPhase(FetchSourceSubPhase.class);
|
|
||||||
registerFetchSubPhase(VersionFetchSubPhase.class);
|
|
||||||
registerFetchSubPhase(MatchedQueriesFetchSubPhase.class);
|
|
||||||
registerFetchSubPhase(HighlightPhase.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerFetchSubPhase(Class<? extends FetchSubPhase> subPhase) {
|
|
||||||
fetchSubPhases.add(subPhase);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<FetchSubPhase> parserMapBinder = Multibinder.newSetBinder(binder(), FetchSubPhase.class);
|
|
||||||
for (Class<? extends FetchSubPhase> clazz : fetchSubPhases) {
|
|
||||||
parserMapBinder.addBinding().to(clazz);
|
|
||||||
}
|
|
||||||
bind(InnerHitsFetchSubPhase.class).asEagerSingleton();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -22,7 +22,6 @@ import com.google.common.collect.Maps;
|
||||||
import org.apache.lucene.search.highlight.Encoder;
|
import org.apache.lucene.search.highlight.Encoder;
|
||||||
import org.apache.lucene.search.vectorhighlight.*;
|
import org.apache.lucene.search.vectorhighlight.*;
|
||||||
import org.apache.lucene.search.vectorhighlight.FieldPhraseList.WeightedPhraseInfo;
|
import org.apache.lucene.search.vectorhighlight.FieldPhraseList.WeightedPhraseInfo;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.text.StringText;
|
import org.elasticsearch.common.text.StringText;
|
||||||
import org.elasticsearch.index.mapper.FieldMapper;
|
import org.elasticsearch.index.mapper.FieldMapper;
|
||||||
|
@ -46,7 +45,6 @@ public class FastVectorHighlighter implements Highlighter {
|
||||||
private static final String CACHE_KEY = "highlight-fsv";
|
private static final String CACHE_KEY = "highlight-fsv";
|
||||||
private final Boolean termVectorMultiValue;
|
private final Boolean termVectorMultiValue;
|
||||||
|
|
||||||
@Inject
|
|
||||||
public FastVectorHighlighter(Settings settings) {
|
public FastVectorHighlighter(Settings settings) {
|
||||||
this.termVectorMultiValue = settings.getAsBoolean("search.highlight.term_vector_multi_value", true);
|
this.termVectorMultiValue = settings.getAsBoolean("search.highlight.term_vector_multi_value", true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.highlight;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class HighlightModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<Class<? extends Highlighter>> highlighters = Lists.newArrayList();
|
|
||||||
|
|
||||||
public HighlightModule() {
|
|
||||||
registerHighlighter(FastVectorHighlighter.class);
|
|
||||||
registerHighlighter(PlainHighlighter.class);
|
|
||||||
registerHighlighter(PostingsHighlighter.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerHighlighter(Class<? extends Highlighter> clazz) {
|
|
||||||
highlighters.add(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<Highlighter> multibinder = Multibinder.newSetBinder(binder(), Highlighter.class);
|
|
||||||
for (Class<? extends Highlighter> highlighter : highlighters) {
|
|
||||||
multibinder.addBinding().to(highlighter);
|
|
||||||
}
|
|
||||||
bind(Highlighters.class).asEagerSingleton();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,28 +21,41 @@ package org.elasticsearch.search.highlight;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Highlighters {
|
public class Highlighters {
|
||||||
private final ImmutableMap<String, Highlighter> parsers;
|
|
||||||
|
private final Map<String, Highlighter> parsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Highlighters(Set<Highlighter> parsers) {
|
public Highlighters(Settings settings, Set<Highlighter> parsers) {
|
||||||
MapBuilder<String, Highlighter> builder = MapBuilder.newMapBuilder();
|
// build in highlighers
|
||||||
for (Highlighter parser : parsers) {
|
Map<String, Highlighter> map = new HashMap<>();
|
||||||
for (String type : parser.names()) {
|
add(map, new FastVectorHighlighter(settings));
|
||||||
builder.put(type, parser);
|
add(map, new PlainHighlighter());
|
||||||
|
add(map, new PostingsHighlighter());
|
||||||
|
for (Highlighter highlighter : parsers) {
|
||||||
|
add(map, highlighter);
|
||||||
}
|
}
|
||||||
}
|
this.parsers = Collections.unmodifiableMap(map);
|
||||||
this.parsers = builder.immutableMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Highlighter get(String type) {
|
public Highlighter get(String type) {
|
||||||
return parsers.get(type);
|
return parsers.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void add(Map<String, Highlighter> map, Highlighter highlighter) {
|
||||||
|
for (String type : highlighter.names()) {
|
||||||
|
map.put(type, highlighter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.suggest;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
|
||||||
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
|
||||||
import org.elasticsearch.search.suggest.completion.CompletionSuggester;
|
|
||||||
import org.elasticsearch.search.suggest.phrase.PhraseSuggester;
|
|
||||||
import org.elasticsearch.search.suggest.term.TermSuggester;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class SuggestModule extends AbstractModule {
|
|
||||||
|
|
||||||
private List<Class<? extends Suggester>> suggesters = Lists.newArrayList();
|
|
||||||
|
|
||||||
public SuggestModule() {
|
|
||||||
registerSuggester(PhraseSuggester.class);
|
|
||||||
registerSuggester(TermSuggester.class);
|
|
||||||
registerSuggester(CompletionSuggester.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void registerSuggester(Class<? extends Suggester> suggester) {
|
|
||||||
suggesters.add(suggester);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
Multibinder<Suggester> suggesterMultibinder = Multibinder.newSetBinder(binder(), Suggester.class);
|
|
||||||
for (Class<? extends Suggester> clazz : suggesters) {
|
|
||||||
suggesterMultibinder.addBinding().to(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
bind(SuggestParseElement.class).asEagerSingleton();
|
|
||||||
bind(SuggestPhase.class).asEagerSingleton();
|
|
||||||
bind(Suggesters.class).asEagerSingleton();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -21,28 +21,42 @@ package org.elasticsearch.search.suggest;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.inject.Inject;
|
import org.elasticsearch.common.inject.Inject;
|
||||||
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
import org.elasticsearch.search.aggregations.bucket.significant.heuristics.SignificanceHeuristicParser;
|
||||||
|
import org.elasticsearch.search.suggest.completion.CompletionSuggester;
|
||||||
|
import org.elasticsearch.search.suggest.phrase.PhraseSuggester;
|
||||||
|
import org.elasticsearch.search.suggest.term.TermSuggester;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Suggesters {
|
public class Suggesters {
|
||||||
private final ImmutableMap<String, Suggester> parsers;
|
private final Map<String, Suggester> parsers;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public Suggesters(Set<Suggester> suggesters) {
|
public Suggesters(Set<Suggester> suggesters, ScriptService scriptService) {
|
||||||
MapBuilder<String, Suggester> builder = MapBuilder.newMapBuilder();
|
final Map<String, Suggester> map = new HashMap<>();
|
||||||
|
add(map, new PhraseSuggester(scriptService));
|
||||||
|
add(map, new TermSuggester());
|
||||||
|
add(map, new CompletionSuggester());
|
||||||
for (Suggester suggester : suggesters) {
|
for (Suggester suggester : suggesters) {
|
||||||
for (String type : suggester.names()) {
|
add(map, suggester);
|
||||||
builder.put(type, suggester);
|
|
||||||
}
|
}
|
||||||
}
|
this.parsers = Collections.unmodifiableMap(map);
|
||||||
this.parsers = builder.immutableMap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Suggester get(String type) {
|
public Suggester get(String type) {
|
||||||
return parsers.get(type);
|
return parsers.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void add(Map<String, Suggester> map, Suggester suggester) {
|
||||||
|
for (String type : suggester.names()) {
|
||||||
|
map.put(type, suggester);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||||
import org.elasticsearch.common.inject.AbstractModule;
|
import org.elasticsearch.common.inject.AbstractModule;
|
||||||
import org.elasticsearch.common.inject.Injector;
|
import org.elasticsearch.common.inject.Injector;
|
||||||
import org.elasticsearch.common.inject.ModulesBuilder;
|
import org.elasticsearch.common.inject.ModulesBuilder;
|
||||||
|
import org.elasticsearch.common.inject.multibindings.Multibinder;
|
||||||
import org.elasticsearch.common.inject.util.Providers;
|
import org.elasticsearch.common.inject.util.Providers;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.SettingsModule;
|
import org.elasticsearch.common.settings.SettingsModule;
|
||||||
|
@ -37,7 +38,8 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.IndexNameModule;
|
import org.elasticsearch.index.IndexNameModule;
|
||||||
import org.elasticsearch.index.analysis.AnalysisModule;
|
import org.elasticsearch.index.analysis.AnalysisModule;
|
||||||
import org.elasticsearch.index.cache.IndexCacheModule;
|
import org.elasticsearch.index.cache.IndexCacheModule;
|
||||||
import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionParser;
|
||||||
|
import org.elasticsearch.index.query.functionscore.ScoreFunctionParserMapper;
|
||||||
import org.elasticsearch.index.settings.IndexSettingsModule;
|
import org.elasticsearch.index.settings.IndexSettingsModule;
|
||||||
import org.elasticsearch.index.similarity.SimilarityModule;
|
import org.elasticsearch.index.similarity.SimilarityModule;
|
||||||
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
|
||||||
|
@ -45,6 +47,7 @@ import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||||
import org.elasticsearch.indices.query.IndicesQueriesModule;
|
import org.elasticsearch.indices.query.IndicesQueriesModule;
|
||||||
import org.elasticsearch.script.ScriptModule;
|
import org.elasticsearch.script.ScriptModule;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.test.ESTestCase;
|
import org.elasticsearch.test.ESTestCase;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
import org.elasticsearch.threadpool.ThreadPoolModule;
|
import org.elasticsearch.threadpool.ThreadPoolModule;
|
||||||
|
@ -84,10 +87,10 @@ public class TemplateQueryParserTest extends ESTestCase {
|
||||||
new AnalysisModule(settings, new IndicesAnalysisService(settings)),
|
new AnalysisModule(settings, new IndicesAnalysisService(settings)),
|
||||||
new SimilarityModule(settings),
|
new SimilarityModule(settings),
|
||||||
new IndexNameModule(index),
|
new IndexNameModule(index),
|
||||||
new FunctionScoreModule(),
|
|
||||||
new AbstractModule() {
|
new AbstractModule() {
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
|
Multibinder.newSetBinder(binder(), ScoreFunctionParser.class);
|
||||||
bind(ClusterService.class).toProvider(Providers.of((ClusterService) null));
|
bind(ClusterService.class).toProvider(Providers.of((ClusterService) null));
|
||||||
bind(CircuitBreakerService.class).to(NoneCircuitBreakerService.class);
|
bind(CircuitBreakerService.class).to(NoneCircuitBreakerService.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.elasticsearch.script.Script;
|
||||||
import org.elasticsearch.script.ScriptModule;
|
import org.elasticsearch.script.ScriptModule;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
import org.elasticsearch.script.ScriptService.ScriptType;
|
import org.elasticsearch.script.ScriptService.ScriptType;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.search.aggregations.Aggregation;
|
import org.elasticsearch.search.aggregations.Aggregation;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
import org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder;
|
||||||
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
import org.elasticsearch.search.aggregations.bucket.filter.InternalFilter;
|
||||||
|
@ -165,11 +166,8 @@ public class SignificantTermsSignificanceScoreIT extends ESIntegTestCase {
|
||||||
return "Significance heuristic plugin";
|
return "Significance heuristic plugin";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(SignificantTermsHeuristicModule significanceModule) {
|
public void onModule(SearchModule significanceModule) {
|
||||||
significanceModule.registerParser(SimpleHeuristic.SimpleHeuristicParser.class);
|
significanceModule.registerHeuristicParser(SimpleHeuristic.SimpleHeuristicParser.class);
|
||||||
}
|
|
||||||
|
|
||||||
public void onModule(TransportSignificantTermsHeuristicModule significanceModule) {
|
|
||||||
significanceModule.registerStream(SimpleHeuristic.STREAM);
|
significanceModule.registerStream(SimpleHeuristic.STREAM);
|
||||||
}
|
}
|
||||||
public void onModule(ScriptModule module) {
|
public void onModule(ScriptModule module) {
|
||||||
|
|
|
@ -81,12 +81,6 @@ public class SignificanceHeuristicTests extends ESTestCase {
|
||||||
// test that stream output can actually be read - does not replace bwc test
|
// test that stream output can actually be read - does not replace bwc test
|
||||||
@Test
|
@Test
|
||||||
public void streamResponse() throws Exception {
|
public void streamResponse() throws Exception {
|
||||||
SignificanceHeuristicStreams.registerStream(MutualInformation.STREAM, MutualInformation.STREAM.getName());
|
|
||||||
SignificanceHeuristicStreams.registerStream(JLHScore.STREAM, JLHScore.STREAM.getName());
|
|
||||||
SignificanceHeuristicStreams.registerStream(PercentageScore.STREAM, PercentageScore.STREAM.getName());
|
|
||||||
SignificanceHeuristicStreams.registerStream(GND.STREAM, GND.STREAM.getName());
|
|
||||||
SignificanceHeuristicStreams.registerStream(ChiSquare.STREAM, ChiSquare.STREAM.getName());
|
|
||||||
SignificanceHeuristicStreams.registerStream(ScriptHeuristic.STREAM, ScriptHeuristic.STREAM.getName());
|
|
||||||
Version version = randomVersion(random());
|
Version version = randomVersion(random());
|
||||||
InternalSignificantTerms[] sigTerms = getRandomSignificantTerms(getRandomSignificanceheuristic());
|
InternalSignificantTerms[] sigTerms = getRandomSignificantTerms(getRandomSignificanceheuristic());
|
||||||
|
|
||||||
|
@ -143,11 +137,7 @@ public class SignificanceHeuristicTests extends ESTestCase {
|
||||||
public void testBuilderAndParser() throws Exception {
|
public void testBuilderAndParser() throws Exception {
|
||||||
|
|
||||||
Set<SignificanceHeuristicParser> parsers = new HashSet<>();
|
Set<SignificanceHeuristicParser> parsers = new HashSet<>();
|
||||||
parsers.add(new JLHScore.JLHScoreParser());
|
SignificanceHeuristicParserMapper heuristicParserMapper = new SignificanceHeuristicParserMapper(parsers, null);
|
||||||
parsers.add(new MutualInformation.MutualInformationParser());
|
|
||||||
parsers.add(new GND.GNDParser());
|
|
||||||
parsers.add(new ChiSquare.ChiSquareParser());
|
|
||||||
SignificanceHeuristicParserMapper heuristicParserMapper = new SignificanceHeuristicParserMapper(parsers);
|
|
||||||
SearchContext searchContext = new SignificantTermsTestSearchContext();
|
SearchContext searchContext = new SignificantTermsTestSearchContext();
|
||||||
|
|
||||||
// test jlh with string
|
// test jlh with string
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.plugins.AbstractPlugin;
|
import org.elasticsearch.plugins.AbstractPlugin;
|
||||||
import org.elasticsearch.search.SearchHitField;
|
import org.elasticsearch.search.SearchHitField;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.search.SearchParseElement;
|
import org.elasticsearch.search.SearchParseElement;
|
||||||
import org.elasticsearch.search.internal.InternalSearchHit;
|
import org.elasticsearch.search.internal.InternalSearchHit;
|
||||||
import org.elasticsearch.search.internal.InternalSearchHitField;
|
import org.elasticsearch.search.internal.InternalSearchHitField;
|
||||||
|
@ -110,8 +111,8 @@ public class FetchSubPhasePluginIT extends ESIntegTestCase {
|
||||||
return "fetch plugin to test if the plugin mechanism works";
|
return "fetch plugin to test if the plugin mechanism works";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(FetchSubPhaseModule fetchSubPhaseModule) {
|
public void onModule(SearchModule searchModule) {
|
||||||
fetchSubPhaseModule.registerFetchSubPhase(TermVectorsFetchSubPhase.class);
|
searchModule.registerFetchSubPhase(TermVectorsFetchSubPhase.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.query.functionscore.DecayFunction;
|
import org.elasticsearch.index.query.functionscore.DecayFunction;
|
||||||
import org.elasticsearch.index.query.functionscore.DecayFunctionBuilder;
|
import org.elasticsearch.index.query.functionscore.DecayFunctionBuilder;
|
||||||
import org.elasticsearch.index.query.functionscore.DecayFunctionParser;
|
import org.elasticsearch.index.query.functionscore.DecayFunctionParser;
|
||||||
import org.elasticsearch.index.query.functionscore.FunctionScoreModule;
|
|
||||||
import org.elasticsearch.plugins.AbstractPlugin;
|
import org.elasticsearch.plugins.AbstractPlugin;
|
||||||
import org.elasticsearch.search.SearchHits;
|
import org.elasticsearch.search.SearchHits;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
|
||||||
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
import org.elasticsearch.test.ESIntegTestCase.Scope;
|
||||||
|
@ -107,8 +107,8 @@ public class FunctionScorePluginIT extends ESIntegTestCase {
|
||||||
return "Distance score plugin to test pluggable implementation";
|
return "Distance score plugin to test pluggable implementation";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(FunctionScoreModule scoreModule) {
|
public void onModule(SearchModule scoreModule) {
|
||||||
scoreModule.registerParser(FunctionScorePluginIT.CustomDistanceScoreParser.class);
|
scoreModule.registerFunctionScoreParser(FunctionScorePluginIT.CustomDistanceScoreParser.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.search.highlight;
|
package org.elasticsearch.search.highlight;
|
||||||
|
|
||||||
import org.elasticsearch.plugins.AbstractPlugin;
|
import org.elasticsearch.plugins.AbstractPlugin;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
|
|
||||||
public class CustomHighlighterPlugin extends AbstractPlugin {
|
public class CustomHighlighterPlugin extends AbstractPlugin {
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ public class CustomHighlighterPlugin extends AbstractPlugin {
|
||||||
return "Custom highlighter to test pluggable implementation";
|
return "Custom highlighter to test pluggable implementation";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(HighlightModule highlightModule) {
|
public void onModule(SearchModule highlightModule) {
|
||||||
highlightModule.registerHighlighter(CustomHighlighter.class);
|
highlightModule.registerHighlighter(CustomHighlighter.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package org.elasticsearch.search.suggest;
|
package org.elasticsearch.search.suggest;
|
||||||
|
|
||||||
import org.elasticsearch.plugins.AbstractPlugin;
|
import org.elasticsearch.plugins.AbstractPlugin;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -35,8 +36,8 @@ public class CustomSuggesterPlugin extends AbstractPlugin {
|
||||||
return "Custom suggester to test pluggable implementation";
|
return "Custom suggester to test pluggable implementation";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onModule(SuggestModule suggestModule) {
|
public void onModule(SearchModule searchModule) {
|
||||||
suggestModule.registerSuggester(CustomSuggester.class);
|
searchModule.registerSuggester(CustomSuggester.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,6 @@ import org.elasticsearch.index.engine.EngineClosedException;
|
||||||
import org.elasticsearch.index.shard.IndexShard;
|
import org.elasticsearch.index.shard.IndexShard;
|
||||||
import org.elasticsearch.index.shard.IndexShardModule;
|
import org.elasticsearch.index.shard.IndexShardModule;
|
||||||
import org.elasticsearch.index.shard.ShardId;
|
import org.elasticsearch.index.shard.ShardId;
|
||||||
import org.elasticsearch.index.store.IndexStoreModule;
|
|
||||||
import org.elasticsearch.indices.IndicesService;
|
import org.elasticsearch.indices.IndicesService;
|
||||||
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
import org.elasticsearch.indices.breaker.CircuitBreakerService;
|
||||||
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
import org.elasticsearch.indices.breaker.HierarchyCircuitBreakerService;
|
||||||
|
@ -99,15 +98,14 @@ import org.elasticsearch.node.Node;
|
||||||
import org.elasticsearch.node.internal.InternalSettingsPreparer;
|
import org.elasticsearch.node.internal.InternalSettingsPreparer;
|
||||||
import org.elasticsearch.node.service.NodeService;
|
import org.elasticsearch.node.service.NodeService;
|
||||||
import org.elasticsearch.script.ScriptService;
|
import org.elasticsearch.script.ScriptService;
|
||||||
|
import org.elasticsearch.search.SearchModule;
|
||||||
import org.elasticsearch.search.SearchService;
|
import org.elasticsearch.search.SearchService;
|
||||||
import org.elasticsearch.search.SearchServiceModule;
|
|
||||||
import org.elasticsearch.test.cache.recycler.MockBigArrays;
|
import org.elasticsearch.test.cache.recycler.MockBigArrays;
|
||||||
import org.elasticsearch.test.cache.recycler.MockPageCacheRecycler;
|
import org.elasticsearch.test.cache.recycler.MockPageCacheRecycler;
|
||||||
import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
|
import org.elasticsearch.test.disruption.ServiceDisruptionScheme;
|
||||||
import org.elasticsearch.test.engine.MockEngineFactory;
|
import org.elasticsearch.test.engine.MockEngineFactory;
|
||||||
import org.elasticsearch.test.search.MockSearchService;
|
import org.elasticsearch.test.search.MockSearchService;
|
||||||
import org.elasticsearch.test.store.MockFSIndexStore;
|
import org.elasticsearch.test.store.MockFSIndexStore;
|
||||||
import org.elasticsearch.test.store.MockFSIndexStoreModule;
|
|
||||||
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
import org.elasticsearch.test.transport.AssertingLocalTransport;
|
||||||
import org.elasticsearch.test.transport.MockTransportService;
|
import org.elasticsearch.test.transport.MockTransportService;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
@ -396,7 +394,7 @@ public final class InternalTestCluster extends TestCluster {
|
||||||
builder.put(IndexShardModule.ENGINE_FACTORY, MockEngineFactory.class);
|
builder.put(IndexShardModule.ENGINE_FACTORY, MockEngineFactory.class);
|
||||||
builder.put(PageCacheRecyclerModule.CACHE_IMPL, MockPageCacheRecycler.class.getName());
|
builder.put(PageCacheRecyclerModule.CACHE_IMPL, MockPageCacheRecycler.class.getName());
|
||||||
builder.put(BigArraysModule.IMPL, MockBigArrays.class.getName());
|
builder.put(BigArraysModule.IMPL, MockBigArrays.class.getName());
|
||||||
builder.put(SearchServiceModule.IMPL, MockSearchService.class.getName());
|
builder.put(SearchModule.SEARCH_SERVICE_IMPL, MockSearchService.class.getName());
|
||||||
}
|
}
|
||||||
if (isLocalTransportConfigured()) {
|
if (isLocalTransportConfigured()) {
|
||||||
builder.extendArray("plugin.types", AssertingLocalTransport.Plugin.class.getName());
|
builder.extendArray("plugin.types", AssertingLocalTransport.Plugin.class.getName());
|
||||||
|
|
|
@ -18,14 +18,18 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.test.engine;
|
package org.elasticsearch.test.engine;
|
||||||
|
|
||||||
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.engine.Engine;
|
import org.elasticsearch.index.engine.Engine;
|
||||||
import org.elasticsearch.index.engine.EngineConfig;
|
import org.elasticsearch.index.engine.EngineConfig;
|
||||||
import org.elasticsearch.index.engine.EngineFactory;
|
import org.elasticsearch.index.engine.EngineFactory;
|
||||||
|
import org.elasticsearch.plugins.AbstractPlugin;
|
||||||
|
import org.elasticsearch.transport.TransportModule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class MockEngineFactory implements EngineFactory {
|
public final class MockEngineFactory implements EngineFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Engine newReadWriteEngine(EngineConfig config, boolean skipTranslogRecovery) {
|
public Engine newReadWriteEngine(EngineConfig config, boolean skipTranslogRecovery) {
|
||||||
return new MockInternalEngine(config, skipTranslogRecovery);
|
return new MockInternalEngine(config, skipTranslogRecovery);
|
||||||
|
|
Loading…
Reference in New Issue