Merge pull request #8352 from jpountz/fix/match_rewrite
Minor fixes to the `match` query.
This commit is contained in:
commit
acf8e2e917
|
@ -123,8 +123,6 @@ public class MatchQueryParser implements QueryParser {
|
|||
}
|
||||
} else if ("minimum_should_match".equals(currentFieldName) || "minimumShouldMatch".equals(currentFieldName)) {
|
||||
minimumShouldMatch = parser.textOrNull();
|
||||
} else if ("rewrite".equals(currentFieldName)) {
|
||||
matchQuery.setRewriteMethod(QueryParsers.parseRewriteMethod(parseContext.parseFieldMatcher(), parser.textOrNull(), null));
|
||||
} else if ("fuzzy_rewrite".equals(currentFieldName) || "fuzzyRewrite".equals(currentFieldName)) {
|
||||
matchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(parseContext.parseFieldMatcher(), parser.textOrNull(), null));
|
||||
} else if ("fuzzy_transpositions".equals(currentFieldName)) {
|
||||
|
|
|
@ -113,8 +113,6 @@ public class MultiMatchQueryParser implements QueryParser {
|
|||
}
|
||||
} else if ("minimum_should_match".equals(currentFieldName) || "minimumShouldMatch".equals(currentFieldName)) {
|
||||
minimumShouldMatch = parser.textOrNull();
|
||||
} else if ("rewrite".equals(currentFieldName)) {
|
||||
multiMatchQuery.setRewriteMethod(QueryParsers.parseRewriteMethod(parseContext.parseFieldMatcher(), parser.textOrNull(), null));
|
||||
} else if ("fuzzy_rewrite".equals(currentFieldName) || "fuzzyRewrite".equals(currentFieldName)) {
|
||||
multiMatchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(parseContext.parseFieldMatcher(), parser.textOrNull(), null));
|
||||
} else if ("use_dis_max".equals(currentFieldName) || "useDisMax".equals(currentFieldName)) {
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.lucene.search.MultiPhrasePrefixQuery;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.common.unit.Fuzziness;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
import org.elasticsearch.index.query.support.QueryParsers;
|
||||
|
@ -68,8 +67,6 @@ public class MatchQuery {
|
|||
|
||||
protected boolean transpositions = FuzzyQuery.defaultTranspositions;
|
||||
|
||||
protected MultiTermQuery.RewriteMethod rewriteMethod;
|
||||
|
||||
protected MultiTermQuery.RewriteMethod fuzzyRewriteMethod;
|
||||
|
||||
protected boolean lenient;
|
||||
|
@ -118,10 +115,6 @@ public class MatchQuery {
|
|||
this.transpositions = transpositions;
|
||||
}
|
||||
|
||||
public void setRewriteMethod(MultiTermQuery.RewriteMethod rewriteMethod) {
|
||||
this.rewriteMethod = rewriteMethod;
|
||||
}
|
||||
|
||||
public void setFuzzyRewriteMethod(MultiTermQuery.RewriteMethod fuzzyRewriteMethod) {
|
||||
this.fuzzyRewriteMethod = fuzzyRewriteMethod;
|
||||
}
|
||||
|
@ -278,10 +271,11 @@ public class MatchQuery {
|
|||
if (query instanceof FuzzyQuery) {
|
||||
QueryParsers.setRewriteMethod((FuzzyQuery) query, fuzzyRewriteMethod);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
int edits = fuzziness.asDistance(term.text());
|
||||
FuzzyQuery query = new FuzzyQuery(term, edits, fuzzyPrefixLength, maxExpansions, transpositions);
|
||||
QueryParsers.setRewriteMethod(query, rewriteMethod);
|
||||
QueryParsers.setRewriteMethod(query, fuzzyRewriteMethod);
|
||||
return query;
|
||||
}
|
||||
if (fieldType != null) {
|
||||
|
|
|
@ -46,7 +46,7 @@ See <<fuzziness>> for allowed settings.
|
|||
|
||||
The `prefix_length` and
|
||||
`max_expansions` can be set in this case to control the fuzzy process.
|
||||
If the fuzzy option is set the query will use `constant_score_rewrite`
|
||||
If the fuzzy option is set the query will use `top_terms_blended_freqs_${max_expansions}`
|
||||
as its <<query-dsl-multi-term-rewrite,rewrite
|
||||
method>> the `fuzzy_rewrite` parameter allows to control how the query will get
|
||||
rewritten.
|
||||
|
|
Loading…
Reference in New Issue