mirror of https://github.com/apache/lucene.git
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:
parent
24136f1fe5
commit
5b4588515b
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
@ -505,4 +506,15 @@ public class TestQueryParser extends QueryParserTestBase {
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue