Adapt to changes to how named writables are registered

This commit is contained in:
Christoph Büscher 2016-08-04 13:40:46 +02:00
parent 1b4b4a6298
commit 438893c0c7
3 changed files with 16 additions and 5 deletions

View File

@ -21,10 +21,13 @@ package org.elasticsearch.index.rankeval;
import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionResponse;
import org.elasticsearch.common.io.stream.NamedWriteable;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.plugins.ActionPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.rest.RestHandler;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -39,4 +42,16 @@ public class RankEvalPlugin extends Plugin implements ActionPlugin {
public List<Class<? extends RestHandler>> getRestHandlers() {
return Arrays.asList(RestRankEvalAction.class);
}
/**
* Returns parsers for {@link NamedWriteable} this plugin will use over the transport protocol.
* @see NamedWriteableRegistry
*/
@Override
public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
List<NamedWriteableRegistry.Entry> metrics = new ArrayList<>();
metrics.add(new NamedWriteableRegistry.Entry(RankedListQualityMetric.class, PrecisionAtN.NAME, PrecisionAtN::new));
metrics.add(new NamedWriteableRegistry.Entry(RankedListQualityMetric.class, ReciprocalRank.NAME, ReciprocalRank::new));
return metrics;
}
}

View File

@ -75,9 +75,6 @@ public class TransportRankEvalAction extends HandledTransportAction<RankEvalRequ
this.searchTransportService = searchTransportService;
this.clusterService = clusterService;
this.actionFilters = actionFilters;
// TODO this should maybe move to some registry on startup
namedWriteableRegistry.register(RankedListQualityMetric.class, PrecisionAtN.NAME, PrecisionAtN::new);
}
@Override

View File

@ -20,7 +20,6 @@
package org.elasticsearch.index.rankeval;
import org.elasticsearch.common.ParseFieldMatcher;
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ParseFieldRegistry;
import org.elasticsearch.common.xcontent.XContentFactory;
@ -52,7 +51,7 @@ public class QuerySpecTests extends ESTestCase {
@BeforeClass
public static void init() throws IOException {
aggsParsers = new AggregatorParsers(new ParseFieldRegistry<>("aggregation"), new ParseFieldRegistry<>("aggregation_pipes"));
searchModule = new SearchModule(Settings.EMPTY, new NamedWriteableRegistry(), false, emptyList());
searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
queriesRegistry = searchModule.getQueryParserRegistry();
suggesters = searchModule.getSuggesters();
}