Copied!

SearchService

SearchService.php : 20
Interface

Constants

publicCAPABILITY_ADVANCED_FULLTEXT

SearchService.php : 96

Capability flag for advanced fulltext feature.

public mixed CAPABILITY_ADVANCED_FULLTEXT = 64

To use with SearchService::supports().

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 : 105

Capability flag for aggregation feature.

public mixed CAPABILITY_AGGREGATIONS = 128

To use with SearchService::supports().

publicCAPABILITY_CUSTOM_FIELDS

SearchService.php : 44

Capability flag for custom fields feature.

public mixed CAPABILITY_CUSTOM_FIELDS = 4

To use with SearchService::supports().

Custom fields is the capability for search engines to:

  • Allow you to extend the search index via plugins to generate custom fields, like a different representation (format, ...) of an existing field or similar.
  • 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_SCORING

SearchService.php : 31

Capability flag for scoring feature.

public mixed CAPABILITY_SCORING = 1

To use with SearchService::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.

publicCAPABILITY_SPELLCHECK

SearchService.php : 57

Capability flag for spellcheck feature.

public mixed CAPABILITY_SPELLCHECK = 8

To use with SearchService::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.

publicCAPABILITY_SUGGEST

SearchService.php : 85

Capability flag for suggest feature.

public mixed CAPABILITY_SUGGEST = 32

To use with SearchService::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.

Methods

publicfindContent()

SearchService.php : 124

Finds content objects for the given query.

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

Parameters

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

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 two syntaxes:

  • ['languages' => [<language_code_string>,…], 'useAlwaysAvailable' => <bool>]
  • [<language_code_string>,…] where useAlwaysAvailable defaults to true to avoid exceptions on missing translations.
$filterOnUserPermissions bool true

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

Return values

SearchResult<string|int, Content>

Tags
Throws
InvalidArgumentException

if query is not valid

publicfindContentInfo()

SearchService.php : 146

Finds contentInfo objects for the given query.

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

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, mixed>|array<int, string> []

Configuration for specifying prioritized languages query will be performed on. Currently, supports two syntaxes:

  • ['languages' => [<language_code_string>,…], 'useAlwaysAvailable' => <bool>]
  • [<language_code_string>,…] where useAlwaysAvailable defaults to true to avoid exceptions on missing translations.
$filterOnUserPermissions bool true

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

Return values

SearchResult<string|int, ContentInfo>

Tags
Throws
InvalidArgumentException

if query is not valid

publicfindLocations()

SearchService.php : 191

Finds Locations for the given query.

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

Parameters

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

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 two syntaxes:

  • ['languages' => [<language_code_string>,…], 'useAlwaysAvailable' => <bool>]
  • [<language_code_string>,…] where useAlwaysAvailable defaults to true to avoid exceptions on missing translations.
$filterOnUserPermissions bool true

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

Return values

SearchResult<string|int, Location>

Tags
Throws
InvalidArgumentException

if query is not valid

publicfindSingle()

SearchService.php : 166

Performs a query for a single content object.

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

Parameters

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

Configuration for specifying prioritized languages query will be performed on. Currently, supports two syntaxes:

  • ['languages' => [<language_code_string>,…], 'useAlwaysAvailable' => <bool>]
  • [<language_code_string>,…] where useAlwaysAvailable defaults to true to avoid exceptions on missing translations.
$filterOnUserPermissions bool true

if true (default), only the objects which the user is 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 : 173

Suggests a list of values for the given prefix.

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

Parameters

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

publicsupports()

SearchService.php : 210

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 the CAPABILITY_* constants (only a single one, not a bitwise combination): CAPABILITY_SCORING, \Ibexa\Contracts\Core\Repository\SearchService::CAPABILITY_FACETS, CAPABILITY_CUSTOM_FIELDS, CAPABILITY_SPELLCHECK,

CAPABILITY_SUGGEST, CAPABILITY_ADVANCED_FULLTEXT, or CAPABILITY_AGGREGATIONS.

Return values

bool