move the fieldName and text ot the parse element so the query can be reused

This commit is contained in:
Shay Banon 2012-08-08 15:06:06 +02:00
parent 055f0809c2
commit 640c0c2933
2 changed files with 4 additions and 10 deletions

View File

@ -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);

View File

@ -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);