summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java
diff options
context:
space:
mode:
authorChristoph Büscher <christoph@elastic.co>2017-07-03 17:30:40 +0200
committerGitHub <noreply@github.com>2017-07-03 17:30:40 +0200
commitf576c987ce2615f77a8de75741b0f5448229805f (patch)
tree11f9e39ce1ad847b65c8c423d99d7c46d8fd7cca /core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java
parent0e2cfc66bb8ad091d3cf5ade2833f9688af1240c (diff)
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.
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java')
-rw-r--r--core/src/main/java/org/elasticsearch/search/suggest/completion/context/ContextMapping.java12
1 files changed, 5 insertions, 7 deletions
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<T extends ToXContent> 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<InternalQueryContext> parseQueryContext(QueryParseContext context) throws IOException, ElasticsearchParseException {
+ public final List<InternalQueryContext> parseQueryContext(XContentParser parser) throws IOException, ElasticsearchParseException {
List<T> 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);
}