Esempio n. 1
0
 /**
  * Extracts search result from $data returned by Elasticsearch.
  *
  * @param mixed $data
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
  */
 public function extract($data)
 {
     $result = new SearchResult(array("time" => $data->took, "maxScore" => $data->hits->max_score, "totalCount" => $data->hits->total));
     if (isset($data->aggregations)) {
         foreach ($data->aggregations as $name => $aggregationData) {
             $result->facets[] = $this->facetBuilderVisitor->map($name, $aggregationData);
         }
     }
     foreach ($data->hits->hits as $hit) {
         $searchHit = new SearchHit(array("score" => $hit->_score, "valueObject" => $this->extractHit($hit)));
         $result->searchHits[] = $searchHit;
     }
     return $result;
 }
 /**
  * Extracts search result from $data returned by Solr backend.
  *
  * @param mixed $data
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
  */
 public function extract($data)
 {
     $result = new SearchResult(array('time' => $data->responseHeader->QTime / 1000, 'maxScore' => $data->response->maxScore, 'totalCount' => $data->response->numFound));
     if (isset($data->facet_counts)) {
         foreach ($data->facet_counts->facet_fields as $field => $facet) {
             $result->facets[] = $this->facetBuilderVisitor->map($field, $facet);
         }
     }
     foreach ($data->response->docs as $doc) {
         $searchHit = new SearchHit(array('score' => $doc->score, 'index' => $this->getIndexIdentifier($doc), 'contentTranslation' => $this->getMatchedLanguageCode($doc), 'valueObject' => $this->extractHit($doc)));
         $result->searchHits[] = $searchHit;
     }
     return $result;
 }