Merge pull request #16085 from MaineC/bug-fix/random-fuzziness-date
Fix for MatchQueryBuilderTests.testToQuery random fuzziness generation caused test failure. Relates to #13284
This commit is contained in:
commit
e7aae1b79e
|
@ -67,6 +67,8 @@ public final class Fuzziness implements ToXContent, Writeable<Fuzziness> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a {@link Fuzziness} instance from an edit distance. The value must be one of <tt>[0, 1, 2]</tt>
|
* Creates a {@link Fuzziness} instance from an edit distance. The value must be one of <tt>[0, 1, 2]</tt>
|
||||||
|
*
|
||||||
|
* Note: Using this method only makes sense if the field you are applying Fuzziness to is some sort of string.
|
||||||
*/
|
*/
|
||||||
public static Fuzziness fromEdits(int edits) {
|
public static Fuzziness fromEdits(int edits) {
|
||||||
return new Fuzziness(edits);
|
return new Fuzziness(edits);
|
||||||
|
|
|
@ -816,12 +816,6 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static Fuzziness randomFuzziness(String fieldName) {
|
protected static Fuzziness randomFuzziness(String fieldName) {
|
||||||
if (randomBoolean()) {
|
|
||||||
return Fuzziness.fromEdits(randomIntBetween(0, 2));
|
|
||||||
}
|
|
||||||
if (randomBoolean()) {
|
|
||||||
return Fuzziness.AUTO;
|
|
||||||
}
|
|
||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
case INT_FIELD_NAME:
|
case INT_FIELD_NAME:
|
||||||
return Fuzziness.build(randomIntBetween(3, 100));
|
return Fuzziness.build(randomIntBetween(3, 100));
|
||||||
|
@ -830,6 +824,9 @@ public abstract class AbstractQueryTestCase<QB extends AbstractQueryBuilder<QB>>
|
||||||
case DATE_FIELD_NAME:
|
case DATE_FIELD_NAME:
|
||||||
return Fuzziness.build(randomTimeValue());
|
return Fuzziness.build(randomTimeValue());
|
||||||
default:
|
default:
|
||||||
|
if (randomBoolean()) {
|
||||||
|
return Fuzziness.fromEdits(randomIntBetween(0, 2));
|
||||||
|
}
|
||||||
return Fuzziness.AUTO;
|
return Fuzziness.AUTO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue