Make registerScoreFunction look like registerQuery

The order of the first two arguments was different on the two register
functions. This makes them consistent.
This commit is contained in:
Nik Everett 2016-04-11 10:27:53 -04:00
parent eb338f46f7
commit 2ed7769ddc
4 changed files with 13 additions and 13 deletions

View File

@ -65,7 +65,7 @@ import java.util.function.BiFunction;
* To write a new decay scoring function, create a new class that extends
* {@link DecayFunctionBuilder}, setup a PARSER field with this class, and
* register them both using
* {@link org.elasticsearch.search.SearchModule#registerScoreFunction(ScoreFunctionParser, Writeable.Reader, ParseField)}.
* {@link org.elasticsearch.search.SearchModule#registerScoreFunction(Writeable.Reader, ScoreFunctionParser, ParseField)}.
* See {@link GaussDecayFunctionBuilder#PARSER} for an example.
*/
public final class DecayFunctionParser<DFB extends DecayFunctionBuilder<DFB>> implements ScoreFunctionParser<DFB> {

View File

@ -295,8 +295,8 @@ public class SearchModule extends AbstractModule {
* {@linkplain ParseField#getPreferredName()}.</li>
* </ul>
*/
public <T extends ScoreFunctionBuilder<T>> void registerScoreFunction(ScoreFunctionParser<T> parser,
Writeable.Reader<T> reader, ParseField functionName) {
public <T extends ScoreFunctionBuilder<T>> void registerScoreFunction(Writeable.Reader<T> reader, ScoreFunctionParser<T> parser,
ParseField functionName) {
for (String name: functionName.getAllNamesIncludedDeprecated()) {
Tuple<ParseField, ScoreFunctionParser<?>> oldValue = scoreFunctionParsers.putIfAbsent(name, new Tuple<>(functionName, parser));
if (oldValue != null) {
@ -507,17 +507,17 @@ public class SearchModule extends AbstractModule {
}
private void registerBuiltinScoreFunctionParsers() {
registerScoreFunction(ScriptScoreFunctionBuilder::fromXContent, ScriptScoreFunctionBuilder::new,
registerScoreFunction(ScriptScoreFunctionBuilder::new, ScriptScoreFunctionBuilder::fromXContent,
ScriptScoreFunctionBuilder.FUNCTION_NAME_FIELD);
registerScoreFunction(GaussDecayFunctionBuilder.PARSER, GaussDecayFunctionBuilder::new,
registerScoreFunction(GaussDecayFunctionBuilder::new, GaussDecayFunctionBuilder.PARSER,
GaussDecayFunctionBuilder.FUNCTION_NAME_FIELD);
registerScoreFunction(LinearDecayFunctionBuilder.PARSER, LinearDecayFunctionBuilder::new,
registerScoreFunction(LinearDecayFunctionBuilder::new, LinearDecayFunctionBuilder.PARSER,
LinearDecayFunctionBuilder.FUNCTION_NAME_FIELD);
registerScoreFunction(ExponentialDecayFunctionBuilder.PARSER, ExponentialDecayFunctionBuilder::new,
registerScoreFunction(ExponentialDecayFunctionBuilder::new, ExponentialDecayFunctionBuilder.PARSER,
ExponentialDecayFunctionBuilder.FUNCTION_NAME_FIELD);
registerScoreFunction(RandomScoreFunctionBuilder::fromXContent, RandomScoreFunctionBuilder::new,
registerScoreFunction(RandomScoreFunctionBuilder::new, RandomScoreFunctionBuilder::fromXContent,
RandomScoreFunctionBuilder.FUNCTION_NAME_FIELD);
registerScoreFunction(FieldValueFactorFunctionBuilder::fromXContent, FieldValueFactorFunctionBuilder::new,
registerScoreFunction(FieldValueFactorFunctionBuilder::new, FieldValueFactorFunctionBuilder::fromXContent,
FieldValueFactorFunctionBuilder.FUNCTION_NAME_FIELD);
//weight doesn't have its own parser, so every function supports it out of the box.

View File

@ -78,8 +78,8 @@ import static org.hamcrest.Matchers.nullValue;
public class FunctionScoreQueryBuilderTests extends AbstractQueryTestCase<FunctionScoreQueryBuilder> {
@BeforeClass
public static void registerTestRandomScoreFunction() {
getSearchModule().registerScoreFunction(RandomScoreFunctionBuilderWithFixedSeed::fromXContent,
RandomScoreFunctionBuilderWithFixedSeed::new, RandomScoreFunctionBuilderWithFixedSeed.FUNCTION_NAME_FIELD);
getSearchModule().registerScoreFunction(RandomScoreFunctionBuilderWithFixedSeed::new,
RandomScoreFunctionBuilderWithFixedSeed::fromXContent, RandomScoreFunctionBuilderWithFixedSeed.FUNCTION_NAME_FIELD);
}
@Override

View File

@ -107,8 +107,8 @@ public class FunctionScorePluginIT extends ESIntegTestCase {
}
public void onModule(SearchModule scoreModule) {
scoreModule.registerScoreFunction(CustomDistanceScoreBuilder.PARSER,
CustomDistanceScoreBuilder::new, CustomDistanceScoreBuilder.FUNCTION_NAME_FIELD);
scoreModule.registerScoreFunction(CustomDistanceScoreBuilder::new, CustomDistanceScoreBuilder.PARSER,
CustomDistanceScoreBuilder.FUNCTION_NAME_FIELD);
}
}