class SearchOptions implements JsonSerializable (View source)

Methods

mixed
jsonSerialize()

Specify data which should be serialized to JSON

timeout(int $ms)

Sets the server side timeout in milliseconds

limit(int $limit)

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

skip(int $skip)

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

explain(bool $explain)

Activates the explanation of each result hit in the response

disableScoring(bool $disabled)

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

consistentWith(string $index, MutationState $state)

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

fields(array $fields)

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

facets(array $facets)

Adds one SearchFacet-s to the query

sort(array $specs)

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

highlight(string $style = null, array $fields = null)

Configures the highlighting of matches in the response

collections(array $collectionNames)

Configures the list of collections to use for restricting results.

Details

mixed jsonSerialize()

Specify data which should be serialized to JSON

Return Value

mixed

data which can be serialized by json_encode, which is a value of any type other than a resource.

SearchOptions timeout(int $ms)

Sets the server side timeout in milliseconds

Parameters

int $ms

the server side timeout to apply

Return Value

SearchOptions

SearchOptions limit(int $limit)

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

Parameters

int $limit

the maximum number of hits to return

Return Value

SearchOptions

SearchOptions skip(int $skip)

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

Parameters

int $skip

the number of results to skip

Return Value

SearchOptions

SearchOptions explain(bool $explain)

Activates the explanation of each result hit in the response

Parameters

bool $explain

Return Value

SearchOptions

SearchOptions disableScoring(bool $disabled)

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

Parameters

bool $disabled

Return Value

SearchOptions

SearchOptions consistentWith(string $index, MutationState $state)

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

This replaces any consistency tuning previously set.

Parameters

string $index
MutationState $state

the mutation state information to work with

Return Value

SearchOptions

SearchOptions fields(array $fields)

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

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

array $fields

Return Value

SearchOptions

SearchOptions facets(array $facets)

Adds one SearchFacet-s to the query

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

array $facets

Return Value

SearchOptions

See also

SearchFacet
TermSearchFacet
NumericRangeSearchFacet
DateRangeSearchFacet

SearchOptions sort(array $specs)

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

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

array $specs

sort the fields that should take part in the sorting.

Return Value

SearchOptions

SearchOptions highlight(string $style = null, array $fields = null)

Configures the highlighting of matches in the response

Parameters

string $style

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

array $fields

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

Return Value

SearchOptions

See also

SearchHighlightMode::HTML
SearchHighlightMode::ANSI
SearchHighlightMode::SIMPLE

SearchOptions collections(array $collectionNames)

Configures the list of collections to use for restricting results.

Parameters

array $collectionNames

Return Value

SearchOptions