Query DSL: Fuzzy Query - add max_expansions, closes #905.
This commit is contained in:
parent
d3076945ac
commit
dffb11bdbf
|
@ -61,6 +61,7 @@ public class FuzzyQueryParser extends AbstractIndexComponent implements XContent
|
||||||
float boost = 1.0f;
|
float boost = 1.0f;
|
||||||
float minSimilarity = FuzzyQuery.defaultMinSimilarity;
|
float minSimilarity = FuzzyQuery.defaultMinSimilarity;
|
||||||
int prefixLength = FuzzyQuery.defaultPrefixLength;
|
int prefixLength = FuzzyQuery.defaultPrefixLength;
|
||||||
|
int maxExpansions = FuzzyQuery.defaultMaxExpansions;
|
||||||
token = parser.nextToken();
|
token = parser.nextToken();
|
||||||
if (token == XContentParser.Token.START_OBJECT) {
|
if (token == XContentParser.Token.START_OBJECT) {
|
||||||
String currentFieldName = null;
|
String currentFieldName = null;
|
||||||
|
@ -78,6 +79,8 @@ public class FuzzyQueryParser extends AbstractIndexComponent implements XContent
|
||||||
minSimilarity = parser.floatValue();
|
minSimilarity = parser.floatValue();
|
||||||
} else if ("prefix_length".equals(currentFieldName) || "prefixLength".equals(currentFieldName)) {
|
} else if ("prefix_length".equals(currentFieldName) || "prefixLength".equals(currentFieldName)) {
|
||||||
prefixLength = parser.intValue();
|
prefixLength = parser.intValue();
|
||||||
|
} else if ("max_expansions".equals(currentFieldName) || "maxExpansions".equals(currentFieldName)) {
|
||||||
|
maxExpansions = parser.intValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +97,7 @@ public class FuzzyQueryParser extends AbstractIndexComponent implements XContent
|
||||||
|
|
||||||
MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);
|
MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);
|
||||||
|
|
||||||
FuzzyQuery fuzzyQuery = new FuzzyQuery(new Term(fieldName, value), minSimilarity, prefixLength);
|
FuzzyQuery fuzzyQuery = new FuzzyQuery(new Term(fieldName, value), minSimilarity, prefixLength, maxExpansions);
|
||||||
fuzzyQuery.setBoost(boost);
|
fuzzyQuery.setBoost(boost);
|
||||||
|
|
||||||
return wrapSmartNameQuery(fuzzyQuery, smartNameFieldMappers, parseContext);
|
return wrapSmartNameQuery(fuzzyQuery, smartNameFieldMappers, parseContext);
|
||||||
|
|
Loading…
Reference in New Issue