LUCENE-6677: QueryParser should pass its maxDeterminizedStates when creating WildcardQuery

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1691066 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-07-14 19:43:34 +00:00
parent 24136f1fe5
commit 5b4588515b
3 changed files with 19 additions and 4 deletions

View File

@ -253,6 +253,9 @@ Bug fixes
* LUCENE-6658: Fix IndexUpgrader to also upgrade indexes without any
segments. (Trejkaz, Uwe Schindler)
* LUCENE-6677: QueryParserBase fails to enforce maxDeterminizedStates when
creating a WildcardQuery (David Causse via Mike McCandless)
Changes in Runtime Behavior
* LUCENE-6501: The subreader structure in ParallelCompositeReader

View File

@ -670,7 +670,7 @@ public abstract class QueryParserBase extends QueryBuilder implements CommonQuer
* @return new WildcardQuery instance
*/
protected Query newWildcardQuery(Term t) {
WildcardQuery query = new WildcardQuery(t);
WildcardQuery query = new WildcardQuery(t, maxDeterminizedStates);
query.setRewriteMethod(multiTermRewriteMethod);
return query;
}

View File

@ -17,8 +17,6 @@ package org.apache.lucene.queryparser.classic;
* limitations under the License.
*/
import java.io.IOException;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.analysis.MockTokenizer;
@ -37,6 +35,9 @@ import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.MultiPhraseQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
import java.io.IOException;
/**
* Tests QueryParser.
@ -504,5 +505,16 @@ public class TestQueryParser extends QueryParserTestBase {
expected.setSlop(3);
assertEquals(expected, qp.parse("\"中国\"~3^2"));
}
/** LUCENE-6677: make sure wildcard query respects maxDeterminizedStates. */
public void testWildcardMaxDeterminizedStates() throws Exception {
QueryParser qp = new QueryParser("field", new MockAnalyzer(random()));
qp.setMaxDeterminizedStates(10);
try {
qp.parse("a*aaaaaaa");
fail("should have hit exception");
} catch (TooComplexToDeterminizeException tctde) {
// expected
}
}
}