Adapt to changes to how named writables are registered
This commit is contained in:
parent
1b4b4a6298
commit
438893c0c7
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue