Documentation

SearchOptions implements JsonSerializable

Table of Contents

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

Methods

jsonSerialize()

public jsonSerialize( ) : mixed
Return values
mixed

timeout()

Sets the server side timeout in milliseconds

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

the server side timeout to apply

Return values
SearchOptions

limit()

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

public limit( $limit : int ) : 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( $skip : int ) : SearchOptions
Parameters
$skip : int

the number of results to skip

Return values
SearchOptions

explain()

Activates the explanation of each result hit in the response

public explain( $explain : bool ) : SearchOptions
Parameters
$explain : bool
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( $index : string , $state : MutationState ) : SearchOptions

This replaces any consistency tuning previously set.

Parameters
$index : string
$state : MutationState

the mutation state information to work with

Return values
SearchOptions

fields()

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

public fields( ...$fields : string ) : 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 : string
Return values
SearchOptions

sort()

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

public sort( $specs : array ) : 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

sort the fields that should take part in the sorting.

Return values
SearchOptions

highlight()

Configures the highlighting of matches in the response

public highlight( [ $style : string = null ] , ...$fields : string ) : 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

Search results