You are here

public function Query::setOption in Search API 8

Sets an option for this search query.

Parameters

string $name: The name of an option. The following options are recognized by default:

  • offset: The position of the first returned search results relative to the whole result in the index.
  • limit: The maximum number of search results to return. -1 means no limit.
  • 'skip result count': If present and set to TRUE, the search's result count will not be needed. Service classes can check for this option to possibly avoid executing expensive operations to compute the result count in cases where it is not needed.
  • search_api_access_account: The account which will be used for entity access checks, if available and enabled for the index.
  • search_api_bypass_access: If set to TRUE, entity access checks will be skipped, even if enabled for the index.
  • search_api_retrieved_field_values: A list of IDs of fields whose values should be returned along with the results by the backend, if possible. For backends that support retrieving fields values, this allows them to only retrieve the values that are actually needed.

However, contrib modules might introduce arbitrary other keys with their own, special meaning. (Usually they should be prefixed with the module name, though, to avoid conflicts.)

mixed $value: The new value of the option.

Return value

mixed The option's previous value, or NULL if none was set.

Overrides QueryInterface::setOption

File

src/Query/Query.php, line 699

Class

Query
Provides a standard implementation for a Search API query.

Namespace

Drupal\search_api\Query

Code

public function setOption($name, $value) {
  $old = $this
    ->getOption($name);
  $this->options[$name] = $value;
  return $old;
}