Search in sources :

Example 1 with MultiGetItem

use of org.springframework.data.elasticsearch.core.MultiGetItem in project spring-data-elasticsearch by spring-projects.

the class SimpleElasticsearchRepository method findAllById.

@Override
public Iterable<T> findAllById(Iterable<ID> ids) {
    Assert.notNull(ids, "ids can't be null.");
    List<T> result = new ArrayList<>();
    Query idQuery = getIdQuery(ids);
    if (isEmpty(idQuery.getIds())) {
        return result;
    }
    List<MultiGetItem<T>> multiGetItems = execute(operations -> operations.multiGet(idQuery, entityClass, getIndexCoordinates()));
    if (multiGetItems != null) {
        multiGetItems.forEach(multiGetItem -> {
            if (multiGetItem.hasItem()) {
                result.add(multiGetItem.getItem());
            }
        });
    }
    return result;
}
Also used : MoreLikeThisQuery(org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery) Query(org.springframework.data.elasticsearch.core.query.Query) NativeSearchQuery(org.springframework.data.elasticsearch.core.query.NativeSearchQuery) MultiGetItem(org.springframework.data.elasticsearch.core.MultiGetItem) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 MultiGetItem (org.springframework.data.elasticsearch.core.MultiGetItem)1 MoreLikeThisQuery (org.springframework.data.elasticsearch.core.query.MoreLikeThisQuery)1 NativeSearchQuery (org.springframework.data.elasticsearch.core.query.NativeSearchQuery)1 Query (org.springframework.data.elasticsearch.core.query.Query)1