From 42291e3cfd57d61986469d5d74068477816780b2 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Thu, 16 Jul 2015 12:11:34 -0400 Subject: [PATCH] QueryString ignores maxDeterminizedStates when creating a WildcardQuery This patch backports https://issues.apache.org/jira/browse/LUCENE-6677 Merges 3ede4c469922308d43fba9ebc63e397ffd6997fe from 1.x --- .../queryparser/classic/MapperQueryParser.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java b/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java index 8dc52f5dc3b..065617ce5ee 100644 --- a/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java +++ b/core/src/main/java/org/apache/lucene/queryparser/classic/MapperQueryParser.java @@ -19,8 +19,6 @@ package org.apache.lucene.queryparser.classic; -import com.google.common.base.Objects; -import com.google.common.collect.ImmutableMap; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; @@ -33,6 +31,8 @@ import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.MultiPhraseQuery; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.search.WildcardQuery; +import org.apache.lucene.util.Version; import org.apache.lucene.util.automaton.RegExp; import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.common.unit.Fuzziness; @@ -42,6 +42,9 @@ import org.elasticsearch.index.mapper.core.DateFieldMapper; import org.elasticsearch.index.query.QueryParseContext; import org.elasticsearch.index.query.support.QueryParsers; +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableMap; + import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -721,6 +724,15 @@ public class MapperQueryParser extends QueryParser { return super.getWildcardQuery(field, aggStr.toString()); } + @Override + protected WildcardQuery newWildcardQuery(Term t) { + // Backport: https://issues.apache.org/jira/browse/LUCENE-6677 + assert Version.LATEST == Version.LUCENE_5_2_1; + WildcardQuery query = new WildcardQuery(t, maxDeterminizedStates); + query.setRewriteMethod(multiTermRewriteMethod); + return query; + } + @Override protected Query getRegexpQuery(String field, String termStr) throws ParseException { if (lowercaseExpandedTerms) {