[TEST] make sure that the random query_string query generator defines a default_field or a list of fields

This commit is contained in:
Jim Ferenczi 2017-04-21 02:56:26 +02:00
parent 4a45579506
commit a4365971a0
2 changed files with 2 additions and 3 deletions

View File

@ -787,7 +787,7 @@ public class MapperQueryParser extends QueryParser {
fields = context.simpleMatchToIndexNames(field); fields = context.simpleMatchToIndexNames(field);
} else { } else {
Map<String, Float> fieldsAndWeights = settings.fieldsAndWeights(); Map<String, Float> fieldsAndWeights = settings.fieldsAndWeights();
fields = fieldsAndWeights == null ? Collections.emptyList() : settings.fieldsAndWeights().keySet(); fields = fieldsAndWeights == null ? Collections.emptyList() : fieldsAndWeights.keySet();
} }
return fields; return fields;
} }

View File

@ -85,8 +85,7 @@ public class QueryStringQueryBuilderTests extends AbstractQueryTestCase<QueryStr
if (randomBoolean()) { if (randomBoolean()) {
queryStringQueryBuilder.defaultField(randomBoolean() ? queryStringQueryBuilder.defaultField(randomBoolean() ?
STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10)); STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10));
} } else {
if (randomBoolean()) {
int numFields = randomIntBetween(1, 5); int numFields = randomIntBetween(1, 5);
for (int i = 0; i < numFields; i++) { for (int i = 0; i < numFields; i++) {
String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10); String fieldName = randomBoolean() ? STRING_FIELD_NAME : randomAlphaOfLengthBetween(1, 10);