Documentation

SearchOptions implements JsonSerializable

Interfaces, Classes and Traits

JsonSerializable

Table of Contents

collections()  : SearchOptions
Configures the list of collections to use for restricting results.
consistentWith()  : SearchOptions
Sets the consistency to consider for this FTS query to AT_PLUS and uses the MutationState to parameterize the consistency.
disableScoring()  : SearchOptions
If set to true, the server will not perform any scoring on the hits
explain()  : SearchOptions
Activates the explanation of each result hit in the response
facets()  : SearchOptions
Adds one SearchFacet-s to the query
fields()  : SearchOptions
Configures the list of fields for which the whole value should be included in the response.
highlight()  : SearchOptions
Configures the highlighting of matches in the response
jsonSerialize()  : mixed
limit()  : SearchOptions
Add a limit to the query on the number of hits it can return
skip()  : SearchOptions
Set the number of hits to skip (eg. for pagination).
sort()  : SearchOptions
Configures the list of fields (including special fields) which are used for sorting purposes.
timeout()  : SearchOptions
Sets the server side timeout in milliseconds

Methods

collections()

Configures the list of collections to use for restricting results.

public collections(array<string|int, string> $collectionNames) : SearchOptions
Parameters
$collectionNames : array<string|int, string>
Return values
SearchOptions

consistentWith()

Sets the consistency to consider for this FTS query to AT_PLUS and uses the MutationState to parameterize the consistency.

public consistentWith(string $index, MutationState $state) : SearchOptions

This replaces any consistency tuning previously set.

Parameters
$index : string
$state : MutationState

the mutation state information to work with

Return values
SearchOptions

disableScoring()

If set to true, the server will not perform any scoring on the hits

public disableScoring(bool $disabled) : SearchOptions
Parameters
$disabled : bool
Return values
SearchOptions

explain()

Activates the explanation of each result hit in the response

public explain(bool $explain) : SearchOptions
Parameters
$explain : bool
Return values
SearchOptions

facets()

Adds one SearchFacet-s to the query

public facets(array<string|int, SearchFacet$facets) : SearchOptions

This is an additive operation (the given facets are added to any facet previously requested), but if an existing facet has the same name it will be replaced.

Note that to be faceted, a field's value must be stored in the FTS index.

Parameters
$facets : array<string|int, SearchFacet>
Tags
see
SearchFacet
see
TermSearchFacet
see
NumericRangeSearchFacet
see
DateRangeSearchFacet
Return values
SearchOptions

fields()

Configures the list of fields for which the whole value should be included in the response.

public fields(array<string|int, string> $fields) : SearchOptions

If empty, no field values are included. This drives the inclusion of the fields in each hit. Note that to be highlighted, the fields must be stored in the FTS index.

Parameters
$fields : array<string|int, string>
Return values
SearchOptions

highlight()

Configures the highlighting of matches in the response

public highlight([string $style = null ], string ...$fields) : SearchOptions
Parameters
$style : string = null

highlight style to apply. Use constants HIGHLIGHT_HTML, HIGHLIGHT_ANSI, HIGHLIGHT_SIMPLE.

$fields : string

the optional fields on which to highlight. If none, all fields where there is a match are highlighted.

Tags
see
SearchHighlightMode::HTML
see
SearchHighlightMode::ANSI
see
SearchHighlightMode::SIMPLE
Return values
SearchOptions

jsonSerialize()

public jsonSerialize() : mixed
Return values
mixed

limit()

Add a limit to the query on the number of hits it can return

public limit(int $limit) : SearchOptions
Parameters
$limit : int

the maximum number of hits to return

Return values
SearchOptions

skip()

Set the number of hits to skip (eg. for pagination).

public skip(int $skip) : SearchOptions
Parameters
$skip : int

the number of results to skip

Return values
SearchOptions

sort()

Configures the list of fields (including special fields) which are used for sorting purposes.

public sort(array<string|int, mixed> $specs) : SearchOptions

If empty, the default sorting (descending by score) is used by the server.

The list of sort fields can include actual fields (like "firstname" but then they must be stored in the index, configured in the server side mapping). Fields provided first are considered first and in a "tie" case the next sort field is considered. So sorting by "firstname" and then "lastname" will first sort ascending by the firstname and if the names are equal then sort ascending by lastname. Special fields like "_id" and "_score" can also be used. If prefixed with "-" the sort order is set to descending.

If no sort is provided, it is equal to sort("-_score"), since the server will sort it by score in descending order.

Parameters
$specs : array<string|int, mixed>

sort the fields that should take part in the sorting.

Return values
SearchOptions

timeout()

Sets the server side timeout in milliseconds

public timeout(int $ms) : SearchOptions
Parameters
$ms : int

the server side timeout to apply

Return values
SearchOptions

Search results