diff --git a/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java b/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java index 909a69e0487..dd82202038f 100644 --- a/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java +++ b/src/main/java/org/elasticsearch/index/query/MatchQueryParser.java @@ -142,7 +142,7 @@ public class MatchQueryParser implements QueryParser { throw new QueryParsingException(parseContext.index(), "No text specified for text query"); } - MatchQuery tQP = new MatchQuery(parseContext, fieldName, text); + MatchQuery tQP = new MatchQuery(parseContext); tQP.setPhraseSlop(phraseSlop); tQP.setAnalyzer(analyzer); tQP.setFuzziness(fuzziness); @@ -152,7 +152,7 @@ public class MatchQueryParser implements QueryParser { tQP.setFuzzyRewriteMethod(fuzzyRewriteMethod); tQP.setOccur(occur); - Query query = tQP.parse(type); + Query query = tQP.parse(type, fieldName, text); if (query instanceof BooleanQuery) { Queries.applyMinimumShouldMatch((BooleanQuery) query, minimumShouldMatch); diff --git a/src/main/java/org/elasticsearch/index/search/MatchQuery.java b/src/main/java/org/elasticsearch/index/search/MatchQuery.java index d308a64ad6b..15040a28de4 100644 --- a/src/main/java/org/elasticsearch/index/search/MatchQuery.java +++ b/src/main/java/org/elasticsearch/index/search/MatchQuery.java @@ -53,10 +53,6 @@ public class MatchQuery { private final QueryParseContext parseContext; - private final String fieldName; - - private final String text; - private String analyzer; private BooleanClause.Occur occur = BooleanClause.Occur.SHOULD; @@ -72,10 +68,8 @@ public class MatchQuery { private MultiTermQuery.RewriteMethod rewriteMethod; private MultiTermQuery.RewriteMethod fuzzyRewriteMethod; - public MatchQuery(QueryParseContext parseContext, String fieldName, String text) { + public MatchQuery(QueryParseContext parseContext) { this.parseContext = parseContext; - this.fieldName = fieldName; - this.text = text; } public void setAnalyzer(String analyzer) { @@ -114,7 +108,7 @@ public class MatchQuery { this.fuzzyRewriteMethod = fuzzyRewriteMethod; } - public Query parse(Type type) { + public Query parse(Type type, String fieldName, String text) { FieldMapper mapper = null; Term fieldTerm; MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);