Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sporadic failures in QueryStringQueryTests#testToQueryFuzzyQueryAutoFuziness #43322

Merged
merged 2 commits into from
Jun 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -787,25 +787,27 @@ public void testEnabledPositionIncrements() throws Exception {

public void testToQueryFuzzyQueryAutoFuziness() throws Exception {
for (int i = 0; i < 3; i++) {
final int len;
final int expectedEdits;
String queryString;
switch (i) {
case 0:
queryString = randomAlphaOfLengthBetween(1, 2);
len = randomIntBetween(1, 2);
expectedEdits = 0;
break;

case 1:
queryString = randomAlphaOfLengthBetween(3, 5);
len = randomIntBetween(3, 5);
expectedEdits = 1;
break;

default:
queryString = randomAlphaOfLengthBetween(6, 20);
len = randomIntBetween(6, 20);
expectedEdits = 2;
break;
}

char[] bytes = new char[len];
Arrays.fill(bytes, 'a');
String queryString = new String(bytes);
for (int j = 0; j < 2; j++) {
Query query = queryStringQuery(queryString + (j == 0 ? "~" : "~auto"))
.defaultField(STRING_FIELD_NAME)
Expand All @@ -817,7 +819,6 @@ public void testToQueryFuzzyQueryAutoFuziness() throws Exception {
}
}
}

public void testFuzzyNumeric() throws Exception {
QueryStringQueryBuilder query = queryStringQuery("12~1.0").defaultField(INT_FIELD_NAME);
QueryShardContext context = createShardContext();
Expand Down