Tests: Allow unmapped fields in SimpleQueryStringBuilderTest#testDefaultOperatorHandling

This commit is contained in:
Christoph Büscher 2015-08-06 19:05:00 +02:00
parent b763265f67
commit 88fe42bc50
1 changed files with 6 additions and 4 deletions

View File

@ -152,16 +152,18 @@ public class SimpleQueryStringBuilderTest extends BaseQueryTestCase<SimpleQueryS
// Check operator handling, and default field handling.
@Test
public void testDefaultOperatorHandling() throws IOException {
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.");
BooleanQuery boolQuery = (BooleanQuery) qb.toQuery(createShardContext());
SimpleQueryStringBuilder qb = new SimpleQueryStringBuilder("The quick brown fox.").field(STRING_FIELD_NAME);
QueryShardContext shardContext = createShardContext();
shardContext.setAllowUnmappedFields(true); // to avoid occasional cases in setup where we didn't add types but strict field resolution
BooleanQuery boolQuery = (BooleanQuery) qb.toQuery(shardContext);
assertThat(shouldClauses(boolQuery), is(4));
qb.defaultOperator(Operator.AND);
boolQuery = (BooleanQuery) qb.toQuery(createShardContext());
boolQuery = (BooleanQuery) qb.toQuery(shardContext);
assertThat(shouldClauses(boolQuery), is(0));
qb.defaultOperator(Operator.OR);
boolQuery = (BooleanQuery) qb.toQuery(createShardContext());
boolQuery = (BooleanQuery) qb.toQuery(shardContext);
assertThat(shouldClauses(boolQuery), is(4));
}