use of core.framework.search.SearchResponse in project core-ng-project by neowu.
the class ElasticSearchTypeImpl method searchResponse.
private SearchResponse<T> searchResponse(org.elasticsearch.action.search.SearchResponse response) {
SearchHit[] hits = response.getHits().getHits();
List<T> items = new ArrayList<>(hits.length);
for (SearchHit hit : hits) {
items.add(reader.fromJSON(BytesReference.toBytes(hit.getSourceRef())));
}
Aggregations aggregationResponse = response.getAggregations();
Map<String, Aggregation> aggregations = aggregationResponse == null ? Maps.newHashMap() : aggregationResponse.asMap();
return new SearchResponse<>(items, response.getHits().getTotalHits(), aggregations);
}
Aggregations