Documentation

SearchOptions
in package
implements JsonSerializable

Interfaces, Classes, Traits and Enums

JsonSerializable

Table of Contents

$collectionNames  : array<string|int, mixed>|null
$consistentWith  : MutationState|null
$disableScoring  : bool|null
$explain  : bool|null
$facets  : array<string|int, mixed>|null
$fields  : array<string|int, mixed>|null
$highlight  : array<string|int, mixed>|null
$includeLocations  : bool|null
$limit  : int|null
$raw  : array<string|int, mixed>|null
$skip  : int|null
$sort  : array<string|int, mixed>|null
$timeoutMilliseconds  : int|null
build()  : SearchOptions
Static helper to keep code more readable
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
includeLocations()  : SearchOptions
If set to true, the result will include search row locations.
limit()  : SearchOptions
Add a limit to the query on the number of hits it can return
raw()  : SearchOptions
Sets any extra query parameters that the SDK does not provide an option for.
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

Properties

$collectionNames

private array<string|int, mixed>|null $collectionNames = null

$facets

private array<string|int, mixed>|null $facets = null

$fields

private array<string|int, mixed>|null $fields = null

$highlight

private array<string|int, mixed>|null $highlight = null

$includeLocations

private bool|null $includeLocations = null

$timeoutMilliseconds

private int|null $timeoutMilliseconds = null

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>
Tags
since
4.0.0
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

Tags
since
4.0.0
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
Tags
since
4.0.0
Return values
SearchOptions

explain()

Activates the explanation of each result hit in the response

public explain(bool $explain) : SearchOptions
Parameters
$explain : bool
Tags
since
4.0.0
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
since
4.0.0
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>
Tags
since
4.0.0
Return values
SearchOptions

highlight()

Configures the highlighting of matches in the response

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

highlight style to apply.

$fields : string

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

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

includeLocations()

If set to true, the result will include search row locations.

public includeLocations(bool $enabled) : SearchOptions
Parameters
$enabled : bool
Tags
since
4.0.0
Return values
SearchOptions

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

Tags
since
4.0.0
Return values
SearchOptions

raw()

Sets any extra query parameters that the SDK does not provide an option for.

public raw(string $key, mixed $value) : SearchOptions
Parameters
$key : string

the name of the parameter

$value : mixed

the value of the parameter

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

Tags
since
4.0.0
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.

Tags
since
4.0.0
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

Tags
since
4.0.0
Return values
SearchOptions

        

Search results