DATAES-832 - findAllById repository method returns iterable with null elements for not found ids.

This commit is contained in:
Peter-Josef Meisch 2020-05-18 18:05:30 +02:00
parent 34e3dc735c
commit 421333dadc

View File

@ -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