Copied!

SearchService

SearchService.php : 20

Search service.

Constants

publicCAPABILITY_ADVANCED_FULLTEXT

SearchService.php : 108

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

public mixed CAPABILITY_ADVANCED_FULLTEXT = 64

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

Tags
See
FullText

publicCAPABILITY_AGGREGATIONS

SearchService.php : 115

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

public mixed CAPABILITY_AGGREGATIONS = 128

publicCAPABILITY_CUSTOM_FIELDS

SearchService.php : 57

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

public mixed CAPABILITY_CUSTOM_FIELDS = 4

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.

publicCAPABILITY_FACETS

SearchService.php : 45

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

public mixed CAPABILITY_FACETS = 2

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

publicCAPABILITY_SCORING

SearchService.php : 31

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

public mixed CAPABILITY_SCORING = 1

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.

publicCAPABILITY_SPELLCHECK

SearchService.php : 70

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

public mixed CAPABILITY_SPELLCHECK = 8

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.

publicCAPABILITY_SUGGEST

SearchService.php : 98

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

public mixed CAPABILITY_SUGGEST = 32

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.

Methods

publicfindContent()

SearchService.php : 131

Finds content objects for the given query.

public findContent(Query $query[, array<string|int, mixed> $languageFilter = [] ][, bool $filterOnUserPermissions = true ]) : SearchResult

Parameters

Name Type Default value Description
$query Query - -
$languageFilter array<string|int, mixed> []

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

$filterOnUserPermissions bool true

if true only the objects which the user is allowed to read are returned.

Return values

SearchResult

Tags
Throws
InvalidArgumentException

if query is not valid

publicfindContentInfo()

SearchService.php : 152

Finds contentInfo objects for the given query.

public findContentInfo(Query $query[, array<string|int, mixed> $languageFilter = [] ][, bool $filterOnUserPermissions = true ]) : SearchResult

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

Name Type Default value Description
$query Query - -
$languageFilter array<string|int, mixed> []

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

$filterOnUserPermissions bool true

if true (default) only the objects which is the user allowed to read are returned.

Return values

SearchResult

Tags
Throws
InvalidArgumentException

if query is not valid

publicfindLocations()

SearchService.php : 194

Finds Locations for the given query.

public findLocations(LocationQuery $query[, array<string|int, mixed> $languageFilter = [] ][, bool $filterOnUserPermissions = true ]) : SearchResult

Parameters

Name Type Default value Description
$query LocationQuery - -
$languageFilter array<string|int, mixed> []

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

$filterOnUserPermissions bool true

if true only the objects which is the user allowed to read are returned.

Return values

SearchResult

Tags
Throws
InvalidArgumentException

if query is not valid

publicfindSingle()

SearchService.php : 169

Performs a query for a single content object.

public findSingle(Criterion $filter[, array<string|int, mixed> $languageFilter = [] ][, bool $filterOnUserPermissions = true ]) : Content

Parameters

Name Type Default value Description
$filter Criterion - -
$languageFilter array<string|int, mixed> []

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

$filterOnUserPermissions bool true

if true only the objects which is the user allowed to read are returned.

Return values

Content

Tags
Throws
NotFoundException

if the object was not found by the query or due to permissions

Throws
InvalidArgumentException

if criterion is not valid

Throws
InvalidArgumentException

if there is more than than one result matching the criterions

publicsuggest()

SearchService.php : 179

Suggests a list of values for the given prefix.

public suggest(string $prefix[, array<string|int, string> $fieldPaths = [] ][, int $limit = 10 ][, Criterion $filter = null ]) : mixed

Parameters

Name Type Default value Description
$prefix string - -
$fieldPaths array<string|int, string> [] -
$limit int 10 -
$filter Criterion null -

publicsupports()

SearchService.php : 207

Query for supported capability of currently configured search engine.

public supports(int $capabilityFlag) : bool

Will return false if search engine does not implement Capable.

Parameters

Name Type Default value Description
$capabilityFlag int -

One of CAPABILITY_* constants.

Return values

bool