From dffb11bdbfb4ae3aa5086cc0df6ce9f725fcb7f0 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 5 May 2011 13:46:19 +0300 Subject: [PATCH] Query DSL: Fuzzy Query - add max_expansions, closes #905. --- .../elasticsearch/index/query/xcontent/FuzzyQueryParser.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FuzzyQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FuzzyQueryParser.java index 0eee5a6c1b7..a4eb7387d67 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FuzzyQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/FuzzyQueryParser.java @@ -61,6 +61,7 @@ public class FuzzyQueryParser extends AbstractIndexComponent implements XContent float boost = 1.0f; float minSimilarity = FuzzyQuery.defaultMinSimilarity; int prefixLength = FuzzyQuery.defaultPrefixLength; + int maxExpansions = FuzzyQuery.defaultMaxExpansions; token = parser.nextToken(); if (token == XContentParser.Token.START_OBJECT) { String currentFieldName = null; @@ -78,6 +79,8 @@ public class FuzzyQueryParser extends AbstractIndexComponent implements XContent minSimilarity = parser.floatValue(); } else if ("prefix_length".equals(currentFieldName) || "prefixLength".equals(currentFieldName)) { 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); - FuzzyQuery fuzzyQuery = new FuzzyQuery(new Term(fieldName, value), minSimilarity, prefixLength); + FuzzyQuery fuzzyQuery = new FuzzyQuery(new Term(fieldName, value), minSimilarity, prefixLength, maxExpansions); fuzzyQuery.setBoost(boost); return wrapSmartNameQuery(fuzzyQuery, smartNameFieldMappers, parseContext);