From f576c987ce2615f77a8de75741b0f5448229805f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Mon, 3 Jul 2017 17:30:40 +0200 Subject: Remove QueryParseContext (#25486) QueryParseContext is currently only used as a wrapper for an XContentParser, so this change removes it entirely and changes the appropriate APIs that use it so far to only accept a parser instead. --- .../search/suggest/completion/context/ContextMapping.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java') diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java index 273138bbb7..697394f3ef 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java @@ -27,7 +27,6 @@ import org.elasticsearch.common.xcontent.XContentParser.Token; import org.elasticsearch.common.xcontent.json.JsonXContent; import org.elasticsearch.index.mapper.CompletionFieldMapper; import org.elasticsearch.index.mapper.ParseContext; -import org.elasticsearch.index.query.QueryParseContext; import java.io.IOException; import java.util.ArrayList; @@ -100,23 +99,22 @@ public abstract class ContextMapping implements ToXContent /** * Prototype for the query context */ - protected abstract T fromXContent(QueryParseContext context) throws IOException; + protected abstract T fromXContent(XContentParser context) throws IOException; /** * Parses query contexts for this mapper */ - public final List parseQueryContext(QueryParseContext context) throws IOException, ElasticsearchParseException { + public final List parseQueryContext(XContentParser parser) throws IOException, ElasticsearchParseException { List queryContexts = new ArrayList<>(); - XContentParser parser = context.parser(); Token token = parser.nextToken(); if (token == Token.START_ARRAY) { while (parser.nextToken() != Token.END_ARRAY) { - queryContexts.add(fromXContent(context)); + queryContexts.add(fromXContent(parser)); } } else { - queryContexts.add(fromXContent(context)); + queryContexts.add(fromXContent(parser)); } - + return toInternalQueryContexts(queryContexts); } -- cgit v1.2.3