Interface

eZ\Publish\API\Repository\SearchService

interface SearchService

Search service.

Constants

CAPABILITY_SCORING

Capability flag for scoring feature for use with {see ::supports()}.

Scoring, a search feature telling you how well one search hit scores compared to other items in the search result. When this is supported you can expect search engine to populate SearchHit->score and SearchResult->maxScore properties as well as sort by this if no sort clauses are specified.

CAPABILITY_FACETS

Capability flag for facets feature for use with {see ::supports()}.

Faceted search: https://en.wikipedia.org/wiki/Faceted_search

Note: Even if search engine tells you this is supported, beware: - It might not support all facets, by design it will only return facets for facet builders the search engine supports. - Some of the faceting features are still work in progress in API and won't be further matured before in 7 .x releases

CAPABILITY_CUSTOM_FIELDS

Capability flag for custom fields feature for use with {see ::supports()}.

Custom fields is the capability for search engines to 1. allow you to extend the search index via plugins to generate custom fields, like a different representation (format, ...) of an existing field or similar. And 2. allow you on some search criteria to specify this custom field to rather query on that instead of the default field generated by the system.

CAPABILITY_SPELLCHECK

Capability flag for spellcheck feature for use with {see ::supports()}.

Spell check within search capabilities refers to ability to suggest better wordings in fulltext search string.

WARNING: This feature is considered experimental given it is not completely designed yet in terms of how it should interact with FullText criterion (singular) which is the most relevant here. Also given how FullText can be part of a more complex criteria it might imply a need to more strictly define where users are supposed to place FullText vs other criteria.

CAPABILITY_HIGHLIGHT

Capability flag for highlight feature for use with {see ::supports()}.

Highlight in search refers to extracting relevant text from the search index that matches the search result, typically returning a chunk of text of a predefined size with matching text highlighted.

WARNING: This feature is considered experimental given it is not completely designed yet in terms of how it should interact with hits within rich content of either eZ or custom field types. it is also unclear how it should hint what part of the highlight is matched.

CAPABILITY_SUGGEST

Capability flag for suggest feature for use with {see ::supports()}.

WARNING: This feature is considered experimental given it is not completely clear what it is supposed to do. Feature might be deprecated in the future.

CAPABILITY_ADVANCED_FULLTEXT

Capability flag for advanced fulltext feature for use with {see ::supports()}.

Advance full text is a feature making to possible by current engine to parse advance full text expressions.

Methods

SearchResult findContent(Query $query, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Finds content objects for the given query.

SearchResult findContentInfo(Query $query, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Finds contentInfo objects for the given query.

Content findSingle(Criterion $filter, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Performs a query for a single content object.

suggest(string $prefix, string[] $fieldPaths = array(), int $limit = 10, Criterion $filter = null)

Suggests a list of values for the given prefix.

SearchResult findLocations(LocationQuery $query, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Finds Locations for the given query.

bool supports(int $capabilityFlag)

Query for supported capability of currently configured search engine.

Details

at line 122
public SearchResult findContent(Query $query, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Finds content objects for the given query.

Parameters

Query $query
array $languageFilter Configuration for specifying prioritized languages query will be performed on. Also used to define which field languages are loaded for the returned content. Currently supports: array("languages" => array(,..), "useAlwaysAvailable" => bool) useAlwaysAvailable defaults to true to avoid exceptions on missing translations
bool $filterOnUserPermissions if true only the objects which the user is allowed to read are returned.

Return Value

SearchResult

Exceptions

InvalidArgumentException if query is not valid

at line 142
public SearchResult findContentInfo(Query $query, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Finds contentInfo objects for the given query.

This method works just like findContent, however does not load the full Content Objects. This means it can be more efficient for use cases where you don't need the full Content. Also including use cases where content will be loaded by separate code, like an ESI based sub requests that takes content ID as input.

Parameters

Query $query
array $languageFilter Configuration for specifying prioritized languages query will be performed on. Currently supports: array("languages" => array(,..), "useAlwaysAvailable" => bool) useAlwaysAvailable defaults to true to avoid exceptions on missing translations
bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned.

Return Value

SearchResult

Exceptions

InvalidArgumentException if query is not valid

at line 159
public Content findSingle(Criterion $filter, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Performs a query for a single content object.

Parameters

Criterion $filter
array $languageFilter Configuration for specifying prioritized languages query will be performed on. Currently supports: array("languages" => array(,..), "useAlwaysAvailable" => bool) useAlwaysAvailable defaults to true to avoid exceptions on missing translations
bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.

Return Value

Content

Exceptions

NotFoundException if the object was not found by the query or due to permissions
InvalidArgumentException if criterion is not valid
InvalidArgumentException if there is more than than one result matching the criterions

at line 169
public suggest(string $prefix, string[] $fieldPaths = array(), int $limit = 10, Criterion $filter = null)

Suggests a list of values for the given prefix.

Parameters

string $prefix
string[] $fieldPaths
int $limit
Criterion $filter

at line 184
public SearchResult findLocations(LocationQuery $query, array $languageFilter = array(), bool $filterOnUserPermissions = true)

Finds Locations for the given query.

Parameters

LocationQuery $query
array $languageFilter Configuration for specifying prioritized languages query will be performed on. Currently supports: array("languages" => array(,..), "useAlwaysAvailable" => bool) useAlwaysAvailable defaults to true to avoid exceptions on missing translations
bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.

Return Value

SearchResult

Exceptions

InvalidArgumentException if query is not valid

at line 197
public bool supports(int $capabilityFlag)

Query for supported capability of currently configured search engine.

Will return false if search engine does not implement {see eZ\Publish\SPI\Search\Capable}.

Parameters

int $capabilityFlag One of CAPABILITY_* constants.

Return Value

bool