You are here

protected function SearchApiElasticsearchQuery::parseResults in Search API Elasticsearch 7.2

Parse Elasticsearch results for use by Search API.

Parameters

ResultSet $result_set:

Return value

array

1 call to SearchApiElasticsearchQuery::parseResults()
SearchApiElasticsearchQuery::search in includes/SearchApiElasticsearchQuery.inc
Execute a search.

File

includes/SearchApiElasticsearchQuery.inc, line 124

Class

SearchApiElasticsearchQuery
@file

Code

protected function parseResults(ResultSet $result_set) {
  $search_result = [
    'results' => [],
  ];
  $search_result['result count'] = $result_set
    ->getTotalHits();
  foreach ($result_set
    ->getResults() as $result) {
    $id = $result
      ->getId();
    $search_result['results'][$id] = [
      'id' => $id,
      'score' => $result
        ->getScore(),
      'fields' => $result
        ->getSource(),
    ];
  }
  $search_result['search_api_facets'] = $this
    ->parseAggregations($result_set);
  return $search_result;
}