コード例 #1
0
ファイル: Native.php プロジェクト: Jenkosama/ezpublish-kernel
 /**
  * Finds Location objects for the given query.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
  */
 public function findLocations(LocationQuery $query)
 {
     $parameters = array("q" => 'document_type_id:"location" AND ' . $this->criterionVisitor->visit($query->query), "fq" => 'document_type_id:"location" AND ' . $this->criterionVisitor->visit($query->filter), "sort" => implode(", ", array_map(array($this->sortClauseVisitor, "visit"), $query->sortClauses)), "fl" => "*,score", "wt" => "json");
     if ($query->offset !== null) {
         $parameters["start"] = $query->offset;
     }
     if ($query->limit !== null) {
         $parameters["rows"] = $query->limit;
     }
     // @todo: Extract method
     $response = $this->client->request('GET', '/solr/select?' . http_build_query($parameters) . (count($query->facetBuilders) ? '&facet=true&facet.sort=count&' : '') . implode('&', array_map(array($this->facetBuilderVisitor, 'visit'), $query->facetBuilders)));
     // @todo: Error handling?
     $data = json_decode($response->body);
     if (!isset($data->response)) {
         throw new \Exception('->response not set: ' . var_export(array($data, $parameters), true));
     }
     // @todo: Extract method
     $result = new SearchResult(array('time' => $data->responseHeader->QTime / 1000, 'maxScore' => $data->response->maxScore, 'totalCount' => $data->response->numFound));
     foreach ($data->response->docs as $doc) {
         $searchHit = new SearchHit(array('score' => $doc->score, 'valueObject' => $this->locationHandler->load(substr($doc->id, 8))));
         $result->searchHits[] = $searchHit;
     }
     if (isset($data->facet_counts)) {
         foreach ($data->facet_counts->facet_fields as $field => $facet) {
             $result->facets[] = $this->facetBuilderVisitor->map($field, $facet);
         }
     }
     return $result;
 }
コード例 #2
0
ファイル: Native.php プロジェクト: Jenkosama/ezpublish-kernel
 /**
  * Purges all contents from the index
  *
  * @return void
  */
 public function purgeIndex()
 {
     $this->client->request('POST', '/solr/update?' . ($this->commit ? "softCommit=true&" : "") . 'wt=json', new Message(array('Content-Type' => 'text/xml'), '<delete><query>*:*</query></delete>'));
 }
コード例 #3
0
ファイル: Native.php プロジェクト: nlescure/ezpublish-kernel
 /**
  * @todo error handling
  *
  * @param $endpoint
  */
 protected function purgeEndpoint($endpoint)
 {
     $this->client->request('POST', $endpoint, '/update?' . ($this->commit ? "softCommit=true&" : "") . 'wt=json', new Message(array('Content-Type' => 'text/xml'), '<delete><query>*:*</query></delete>'));
 }