Skip to content

Commit d9fd722

Browse files
authored
Fix IndicesBoost error.
Original Pull Request #2606 Closes #2598
1 parent e202772 commit d9fd722

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/main/java/org/springframework/data/elasticsearch/client/elc/RequestConverter.java

+6-10
Original file line numberDiff line numberDiff line change
@@ -1250,11 +1250,9 @@ public MsearchRequest searchMsearchRequest(
12501250
}
12511251

12521252
if (!isEmpty(query.getIndicesBoost())) {
1253-
Map<String, Double> boosts = new LinkedHashMap<>();
1254-
query.getIndicesBoost()
1255-
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
1256-
// noinspection unchecked
1257-
bb.indicesBoost(boosts);
1253+
bb.indicesBoost(query.getIndicesBoost().stream()
1254+
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
1255+
.collect(Collectors.toList()));
12581256
}
12591257

12601258
query.getScriptedFields().forEach(scriptedField -> bb.scriptFields(scriptedField.getFieldName(),
@@ -1419,11 +1417,9 @@ private <T> void prepareSearchRequest(Query query, @Nullable String routing, @Nu
14191417
}
14201418

14211419
if (!isEmpty(query.getIndicesBoost())) {
1422-
Map<String, Double> boosts = new LinkedHashMap<>();
1423-
query.getIndicesBoost()
1424-
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
1425-
// noinspection unchecked
1426-
builder.indicesBoost(boosts);
1420+
builder.indicesBoost(query.getIndicesBoost().stream()
1421+
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
1422+
.collect(Collectors.toList()));
14271423
}
14281424

14291425
if (!isEmpty(query.getDocValueFields())) {

0 commit comments

Comments
 (0)