Example usage for org.springframework.data.elasticsearch.core.aggregation.impl AggregatedPageImpl AggregatedPageImpl

List of usage examples for org.springframework.data.elasticsearch.core.aggregation.impl AggregatedPageImpl AggregatedPageImpl

Introduction

In this page you can find the example usage for org.springframework.data.elasticsearch.core.aggregation.impl AggregatedPageImpl AggregatedPageImpl.

Prototype

public AggregatedPageImpl(List<T> content, Pageable pageable, long total, Aggregations aggregations) 

Source Link

Usage

From source file:org.springframework.data.elasticsearch.core.DefaultResultMapper.java

@Override
public <T> AggregatedPage<T> mapResults(SearchResponse response, Class<T> clazz, Pageable pageable) {
    long totalHits = response.getHits().totalHits();
    List<T> results = new ArrayList<T>();
    for (SearchHit hit : response.getHits()) {
        if (hit != null) {
            T result = null;//from  w  w  w.j  a va  2s  . c o  m
            if (StringUtils.isNotBlank(hit.sourceAsString())) {
                result = mapEntity(hit.sourceAsString(), clazz);
            } else {
                result = mapEntity(hit.getFields().values(), clazz);
            }
            setPersistentEntityId(result, hit.getId(), clazz);
            populateScriptFields(result, hit);
            results.add(result);
        }
    }

    return new AggregatedPageImpl<T>(results, pageable, totalHits, response.getAggregations());
}