Skip to content

Commit 121b47e

Browse files
committed
Fix IndicesBoost error.
Original Pull Request #2606 Closes #2598 (cherry picked from commit d9fd722)
1 parent 3abe6d9 commit 121b47e

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
@@ -1246,11 +1246,9 @@ public MsearchRequest searchMsearchRequest(
12461246
}
12471247

12481248
if (!isEmpty(query.getIndicesBoost())) {
1249-
Map<String, Double> boosts = new LinkedHashMap<>();
1250-
query.getIndicesBoost()
1251-
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
1252-
// noinspection unchecked
1253-
bb.indicesBoost(boosts);
1249+
bb.indicesBoost(query.getIndicesBoost().stream()
1250+
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
1251+
.collect(Collectors.toList()));
12541252
}
12551253

12561254
query.getScriptedFields().forEach(scriptedField -> bb.scriptFields(scriptedField.getFieldName(),
@@ -1412,11 +1410,9 @@ private <T> void prepareSearchRequest(Query query, @Nullable String routing, @Nu
14121410
}
14131411

14141412
if (!isEmpty(query.getIndicesBoost())) {
1415-
Map<String, Double> boosts = new LinkedHashMap<>();
1416-
query.getIndicesBoost()
1417-
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
1418-
// noinspection unchecked
1419-
builder.indicesBoost(boosts);
1413+
builder.indicesBoost(query.getIndicesBoost().stream()
1414+
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
1415+
.collect(Collectors.toList()));
14201416
}
14211417

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

0 commit comments

Comments
 (0)