mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-24 04:52:12 +00:00
DATAES-832 - findAllById repository method returns iterable with null elements for not found ids.
This commit is contained in:
parent
34e3dc735c
commit
421333dadc
@ -154,10 +154,21 @@ public abstract class AbstractElasticsearchRepository<T, ID> implements Elastics
|
||||
|
||||
@Override
|
||||
public Iterable<T> findAllById(Iterable<ID> ids) {
|
||||
|
||||
Assert.notNull(ids, "ids can't be null.");
|
||||
|
||||
NativeSearchQuery query = new NativeSearchQueryBuilder().withIds(stringIdsRepresentation(ids)).build();
|
||||
return operations.multiGet(query, getEntityClass(), getIndexCoordinates()).stream().filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
List<T> result = new ArrayList<>();
|
||||
List<T> multiGetEntities = operations.multiGet(query, getEntityClass(), getIndexCoordinates());
|
||||
|
||||
multiGetEntities.forEach(entity -> {
|
||||
|
||||
if (entity != null) {
|
||||
result.add(entity);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user