SOLR-13190 Fix for failing test

This commit is contained in:
Mike Drob 2019-12-19 18:37:53 -06:00
parent aab3c5faa3
commit 1333bd10a7
2 changed files with 8 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.apache.lucene.util.automaton.LevenshteinAutomata;
import org.apache.lucene.util.automaton.Operations;
import org.apache.lucene.util.automaton.TooComplexToDeterminizeException;
/** Implements the fuzzy search query. The similarity measurement
* is based on the Damerau-Levenshtein (optimal string alignment) algorithm,
@ -163,8 +164,12 @@ public class FuzzyQuery extends MultiTermQuery {
visitor.consumeTerms(this, term);
} else {
// Note: we're rebuilding the automaton here, so this can be expensive
visitor.consumeTermsMatching(this, field,
new ByteRunAutomaton(toAutomaton(), false, Operations.DEFAULT_MAX_DETERMINIZED_STATES));
try {
visitor.consumeTermsMatching(this, field,
new ByteRunAutomaton(toAutomaton(), false, Operations.DEFAULT_MAX_DETERMINIZED_STATES));
} catch (TooComplexToDeterminizeException e) {
throw new FuzzyTermsEnum.FuzzyTermsException(term.text(), e);
}
}
}
}

View File

@ -419,7 +419,7 @@ public final class FuzzyTermsEnum extends BaseTermsEnum {
* but also possible with shorter terms consisting of UTF-32 code points.
*/
public static class FuzzyTermsException extends RuntimeException {
private FuzzyTermsException(String term, Throwable cause) {
FuzzyTermsException(String term, Throwable cause) {
super("Term too complex: " + term, cause);
}
}