Fix CI failure for recent commit in SimpleQueryStringBuilder
This commit is contained in:
parent
1672bcc21c
commit
fdcfc7e817
|
@ -287,17 +287,20 @@ public class SimpleQueryStringBuilder extends AbstractQueryBuilder<SimpleQuerySt
|
||||||
sqp.setDefaultOperator(defaultOperator.toBooleanClauseOccur());
|
sqp.setDefaultOperator(defaultOperator.toBooleanClauseOccur());
|
||||||
|
|
||||||
Query query = sqp.parse(queryText);
|
Query query = sqp.parse(queryText);
|
||||||
if (minimumShouldMatch != null && query instanceof BooleanQuery) {
|
if (query instanceof BooleanQuery) {
|
||||||
BooleanQuery booleanQuery = (BooleanQuery) query;
|
BooleanQuery booleanQuery = (BooleanQuery) query;
|
||||||
// treat special case for one term query and more than one field
|
|
||||||
// we need to wrap this in additional BooleanQuery so minimum_should_match is applied correctly
|
|
||||||
if (booleanQuery.clauses().size() > 1
|
if (booleanQuery.clauses().size() > 1
|
||||||
&& ((booleanQuery.clauses().iterator().next().getQuery() instanceof BooleanQuery) == false)) {
|
&& ((booleanQuery.clauses().iterator().next().getQuery() instanceof BooleanQuery) == false)) {
|
||||||
|
// special case for one term query and more than one field: (f1:t1 f2:t1 f3:t1)
|
||||||
|
// we need to wrap this in additional BooleanQuery so minimum_should_match is applied correctly
|
||||||
BooleanQuery.Builder builder = new BooleanQuery.Builder();
|
BooleanQuery.Builder builder = new BooleanQuery.Builder();
|
||||||
builder.add(new BooleanClause(booleanQuery, Occur.SHOULD));
|
builder.add(new BooleanClause(booleanQuery, Occur.SHOULD));
|
||||||
booleanQuery = builder.build();
|
booleanQuery = builder.build();
|
||||||
}
|
}
|
||||||
query = Queries.applyMinimumShouldMatch(booleanQuery, minimumShouldMatch);
|
if (minimumShouldMatch != null) {
|
||||||
|
booleanQuery = Queries.applyMinimumShouldMatch(booleanQuery, minimumShouldMatch);
|
||||||
|
}
|
||||||
|
query = booleanQuery;
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue