/** * Get SearchService. * * @return \eZ\Publish\API\Repository\SearchService */ public function getSearchService() { if ($this->searchService !== null) { return $this->searchService; } $this->searchService = new SearchService($this, $this->searchHandler->contentSearchHandler(), $this->searchHandler->locationSearchHandler(), $this->getDomainMapper(), $this->getPermissionsCriterionHandler(), $this->serviceSettings['search']); return $this->searchService; }
/** * Performs a query for a single content object * * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if criterion is not valid * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is more than one result matching the criterions * * @todo define structs for the field filters * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter * @param array $fieldFilters - a map of filters for the returned fields. * Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code> * useAlwaysAvailable defaults to true to avoid exceptions on missing translations. * @param boolean $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. * * @return \eZ\Publish\API\Repository\Values\Content\Content */ public function findSingle(Criterion $filter, array $fieldFilters = array(), $filterOnUserPermissions = true) { $this->validateContentCriteria(array($filter), "\$filter"); if ($filterOnUserPermissions && !$this->permissionsCriterionHandler->addPermissionsCriterion($filter)) { throw new NotFoundException('Content', '*'); } $contentInfo = $this->searchHandler->findSingle($filter, $fieldFilters); return $this->repository->getContentService()->loadContent($contentInfo->id, !empty($fieldFilters['languages']) ? $fieldFilters['languages'] : null, null, isset($fieldFilters['useAlwaysAvailable']) ? $fieldFilters['useAlwaysAvailable'] : true); }
/** * Purges the index. */ public function cleanup() { // Indexing is not implemented in eZ Publish 5 legacy search engine if ($this->searchEngine == 'legacy') { $db = eZDB::instance(); $db->begin(); $db->query("DELETE FROM ezsearch_word"); $db->query("DELETE FROM ezsearch_object_word_link"); $db->commit(); } else { if (method_exists($this->searchHandler, 'purgeIndex')) { $this->searchHandler->purgeIndex(); } } }
/** * Finds Locations for the given query. * * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid * * @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on. * Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code> * useAlwaysAvailable defaults to true to avoid exceptions on missing translations * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned. * * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult */ public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true) { if (!is_int($query->offset)) { throw new InvalidArgumentType('$query->offset', 'integer', $query->offset); } if (!is_int($query->limit)) { throw new InvalidArgumentType('$query->limit', 'integer', $query->limit); } $query = clone $query; $query->filter = $query->filter ?: new Criterion\MatchAll(); if ($filterOnUserPermissions && !$this->permissionsCriterionHandler->addPermissionsCriterion($query->filter)) { return new SearchResult(array('time' => 0, 'totalCount' => 0)); } $result = $this->searchHandler->findLocations($query, $languageFilter); foreach ($result->searchHits as $hit) { $hit->valueObject = $this->domainMapper->buildLocationDomainObject($hit->valueObject); } return $result; }