From 438893c0c7e1474d18a1aff40ef5ea4c858acf05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 4 Aug 2016 13:40:46 +0200 Subject: [PATCH] Adapt to changes to how named writables are registered --- .../index/rankeval/RankEvalPlugin.java | 15 +++++++++++++++ .../index/rankeval/TransportRankEvalAction.java | 3 --- .../index/rankeval/QuerySpecTests.java | 3 +-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalPlugin.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalPlugin.java index 7aed80fc481..bb59ff6051f 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalPlugin.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/RankEvalPlugin.java @@ -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> getRestHandlers() { return Arrays.asList(RestRankEvalAction.class); } + + /** + * Returns parsers for {@link NamedWriteable} this plugin will use over the transport protocol. + * @see NamedWriteableRegistry + */ + @Override + public List getNamedWriteables() { + List 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; + } } diff --git a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java index ee978b7823b..7b13014e310 100644 --- a/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java +++ b/modules/rank-eval/src/main/java/org/elasticsearch/index/rankeval/TransportRankEvalAction.java @@ -75,9 +75,6 @@ public class TransportRankEvalAction extends HandledTransportAction("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(); }