Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten SearchService and clean up build-in registration #12807

Merged
merged 1 commit into from
Aug 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import org.elasticsearch.node.internal.InternalSettingsPreparer;
import org.elasticsearch.plugins.PluginsModule;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.search.TransportSearchModule;
import org.elasticsearch.search.SearchModule;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.threadpool.ThreadPoolModule;
import org.elasticsearch.transport.TransportModule;
Expand Down Expand Up @@ -138,8 +138,13 @@ public TransportClient build() {
modules.add(new NetworkModule());
modules.add(new ClusterNameModule(this.settings));
modules.add(new ThreadPoolModule(threadPool));
modules.add(new TransportSearchModule());
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 ClientTransportModule());
modules.add(new CircuitBreakerModule(this.settings));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,42 @@

package org.elasticsearch.index.query.functionscore;

import com.google.common.collect.ImmutableMap;

import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.index.query.QueryParseContext;
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;

public class ScoreFunctionParserMapper {

protected ImmutableMap<String, ScoreFunctionParser> functionParsers;
protected Map<String, ScoreFunctionParser> functionParsers;

@Inject
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 (String name : scoreFunctionParser.getNames()) {
builder.put(name, scoreFunctionParser);
}
addParser(scoreFunctionParser, map);
}
this.functionParsers = builder.immutableMap();
this.functionParsers = Collections.unmodifiableMap(map);
}

public ScoreFunctionParser get(QueryParseContext parseContext, String parserName) {
Expand All @@ -55,4 +69,10 @@ private ScoreFunctionParser get(String parserName) {
return functionParsers.get(parserName);
}

private void addParser(ScoreFunctionParser scoreFunctionParser, Map<String, ScoreFunctionParser> map) {
for (String name : scoreFunctionParser.getNames()) {
map.put(name, scoreFunctionParser);
}
}

}
Loading