InternalFacets facets = null;
if (response.getFacets() != null) {
facets = new InternalFacets(response.getFacets().facets());
}
InternalAggregations aggregations = null;
if (response.getAggregations() != null) {
aggregations = new InternalAggregations(toInternal(response.getAggregations().asList()));
}
return new SearchResponse(
new InternalSearchResponse(
new InternalSearchHits(trimmedHits, allHits.getTotalHits(), allHits.getMaxScore()),