mirror of https://github.com/apache/lucene.git
LUCENE-9098 Use multibyte code-points for complex fuzzy query (#1194)
This commit is contained in:
parent
8894babd4a
commit
ec6a9aab09
|
@ -499,21 +499,31 @@ public class TestFuzzyQuery extends LuceneTestCase {
|
|||
assertTrue(expected.getMessage().contains("maxExpansions must be positive"));
|
||||
}
|
||||
|
||||
private String randomRealisticMultiByteUnicode(int length) {
|
||||
while (true) {
|
||||
// There is 1 single-byte unicode block, and 194 multi-byte blocks
|
||||
String value = RandomizedTest.randomRealisticUnicodeOfCodepointLength(length);
|
||||
if (value.charAt(0) > Byte.MAX_VALUE) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testErrorMessage() {
|
||||
// 45 states per vector from Lev2TParametricDescription
|
||||
int length = (Operations.DEFAULT_MAX_DETERMINIZED_STATES / 45) + 10;
|
||||
final int length = (Operations.DEFAULT_MAX_DETERMINIZED_STATES / 45) + 10;
|
||||
final String value = randomRealisticMultiByteUnicode(length);
|
||||
|
||||
String value = RandomizedTest.randomRealisticUnicodeOfCodepointLength(length);
|
||||
FuzzyTermsEnum.FuzzyTermsException expected = expectThrows(FuzzyTermsEnum.FuzzyTermsException.class, () -> {
|
||||
new FuzzyQuery(new Term("field", value)).getTermsEnum(new Terms() {
|
||||
@Override
|
||||
public TermsEnum iterator() {
|
||||
throw new UnsupportedOperationException();
|
||||
return TermsEnum.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long size() {
|
||||
throw new UnsupportedOperationException();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue