twosom commented on code in PR #12040:
URL: https://github.com/apache/lucene/pull/12040#discussion_r1057624186
##########
lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java:
##########
@@ -408,19 +393,15 @@ public Query rewrite(IndexSearcher indexSearcher) throws
IOException {
if (shouldClauses.size() != clauseSets.get(Occur.SHOULD).size()) {
BooleanQuery.Builder builder =
new
BooleanQuery.Builder().setMinimumNumberShouldMatch(minimumNumberShouldMatch);
- for (Map.Entry<Query, Double> entry : shouldClauses.entrySet()) {
- Query query = entry.getKey();
- float boost = entry.getValue().floatValue();
- if (boost != 1f) {
- query = new BoostQuery(query, boost);
- }
- builder.add(query, Occur.SHOULD);
- }
- for (BooleanClause clause : clauses) {
- if (clause.getOccur() != Occur.SHOULD) {
- builder.add(clause);
- }
- }
+ shouldClauses.forEach(
+ (query, value) -> {
+ float boost = value.floatValue();
+ if (boost != 1f) {
+ query = new BoostQuery(query, boost);
+ }
+ builder.add(query, Occur.SHOULD);
+ });
+ clauses.stream().filter(clause -> clause.getOccur() !=
Occur.SHOULD).forEach(builder::add);
Review Comment:
and this stream too.
`clauses.stream().filter(BooleanClause::isNotShould).forEach(builder::add);`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]