diff --git a/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java b/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java index f084705affd..211aebf869e 100644 --- a/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java +++ b/core/src/test/java/org/elasticsearch/index/query/plugin/DummyQueryParserPlugin.java @@ -30,7 +30,6 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.QueryParseContext; -import org.elasticsearch.index.query.QueryParser; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.plugins.Plugin; import org.elasticsearch.search.SearchModule; @@ -50,17 +49,24 @@ public class DummyQueryParserPlugin extends Plugin { } public void onModule(SearchModule module) { - module.registerQueryParser(new DummyQueryParser(), new ParseField(DummyQueryBuilder.NAME)); + module.registerQuery(new DummyQueryBuilder()::readFrom, DummyQueryBuilder::fromXContent, DummyQueryBuilder.QUERY_NAME_FIELD); } public static class DummyQueryBuilder extends AbstractQueryBuilder { private static final String NAME = "dummy"; + private static final ParseField QUERY_NAME_FIELD = new ParseField(NAME); @Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME).endObject(); } + public static DummyQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { + XContentParser.Token token = parseContext.parser().nextToken(); + assert token == XContentParser.Token.END_OBJECT; + return new DummyQueryBuilder(); + } + @Override protected Query doToQuery(QueryShardContext context) throws IOException { return new DummyQuery(context.isFilter()); @@ -92,20 +98,6 @@ public class DummyQueryParserPlugin extends Plugin { } } - public static class DummyQueryParser implements QueryParser { - @Override - public DummyQueryBuilder fromXContent(QueryParseContext parseContext) throws IOException { - XContentParser.Token token = parseContext.parser().nextToken(); - assert token == XContentParser.Token.END_OBJECT; - return new DummyQueryBuilder(); - } - - @Override - public DummyQueryBuilder getBuilderPrototype() { - return new DummyQueryBuilder(); - } - } - public static class DummyQuery extends Query { public final boolean isFilter; private final Query matchAllDocsQuery = new MatchAllDocsQuery();