Skip to content

Commit 31365fb

Browse files
committed
Fix IndicesBoost error.
Original Pull Request #2606 Closes #2598 (cherry picked from commit d9fd722)
1 parent c218c1d commit 31365fb

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

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,11 +1146,9 @@ public MsearchRequest searchMsearchRequest(
11461146
}
11471147

11481148
if (!isEmpty(query.getIndicesBoost())) {
1149-
Map<String, Double> boosts = new LinkedHashMap<>();
1150-
query.getIndicesBoost()
1151-
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
1152-
// noinspection unchecked
1153-
bb.indicesBoost(boosts);
1149+
bb.indicesBoost(query.getIndicesBoost().stream()
1150+
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
1151+
.collect(Collectors.toList()));
11541152
}
11551153

11561154
if (query instanceof NativeQuery) {
@@ -1301,11 +1299,9 @@ private <T> void prepareSearchRequest(Query query, @Nullable Class<T> clazz, Ind
13011299
}
13021300

13031301
if (!isEmpty(query.getIndicesBoost())) {
1304-
Map<String, Double> boosts = new LinkedHashMap<>();
1305-
query.getIndicesBoost()
1306-
.forEach(indexBoost -> boosts.put(indexBoost.getIndexName(), (double) indexBoost.getBoost()));
1307-
// noinspection unchecked
1308-
builder.indicesBoost(boosts);
1302+
builder.indicesBoost(query.getIndicesBoost().stream()
1303+
.map(indexBoost -> Map.of(indexBoost.getIndexName(), Double.valueOf(indexBoost.getBoost())))
1304+
.collect(Collectors.toList()));
13091305
}
13101306
}
13111307

0 commit comments

Comments
 (0)