Fix MatchQueryParser not parsing fuzzy_transpositions
This commit is contained in:
parent
3f2f1f088d
commit
15ff3df243
|
@ -126,7 +126,7 @@ public class MatchQueryParser implements QueryParser {
|
|||
matchQuery.setRewriteMethod(QueryParsers.parseRewriteMethod(parser.textOrNull(), null));
|
||||
} else if ("fuzzy_rewrite".equals(currentFieldName) || "fuzzyRewrite".equals(currentFieldName)) {
|
||||
matchQuery.setFuzzyRewriteMethod(QueryParsers.parseRewriteMethod(parser.textOrNull(), null));
|
||||
} else if ("fuzzy_transpositions".equals(fieldName)) {
|
||||
} else if ("fuzzy_transpositions".equals(currentFieldName)) {
|
||||
matchQuery.setTranspositions(parser.booleanValue());
|
||||
} else if ("lenient".equals(currentFieldName)) {
|
||||
matchQuery.setLenient(parser.booleanValue());
|
||||
|
|
|
@ -2355,4 +2355,24 @@ public class SimpleIndexQueryParserTests extends ElasticsearchTestCase {
|
|||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(BooleanQuery.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchWithFuzzyTranspositions() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/match-with-fuzzy-transpositions.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(FuzzyQuery.class));
|
||||
assertThat( ((FuzzyQuery) parsedQuery).getTranspositions(), equalTo(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMatchWithoutFuzzyTranspositions() throws Exception {
|
||||
IndexQueryParserService queryParser = queryParser();
|
||||
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/match-without-fuzzy-transpositions.json");
|
||||
Query parsedQuery = queryParser.parse(query).query();
|
||||
assertThat(parsedQuery, instanceOf(FuzzyQuery.class));
|
||||
assertThat( ((FuzzyQuery) parsedQuery).getTranspositions(), equalTo(false));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{ "match": { "body": { "query": "fuzzy", "fuzziness": 1, "fuzzy_transpositions": true }} }
|
|
@ -0,0 +1 @@
|
|||
{ "match": { "body": { "query": "fuzzy", "fuzziness": 1, "fuzzy_transpositions": false }} }
|
Loading…
Reference in New Issue