You are here

public function Query::__construct in Search API 8

Constructs a Query object.

Parameters

\Drupal\search_api\IndexInterface $index: The index the query should be executed on.

array $options: (optional) Associative array of options configuring this query. See \Drupal\search_api\Query\QueryInterface::setOption() for a list of options that are recognized by default.

Throws

\Drupal\search_api\SearchApiException Thrown if a search on that index (or with those options) won't be possible.

File

src/Query/Query.php, line 215

Class

Query
Provides a standard implementation for a Search API query.

Namespace

Drupal\search_api\Query

Code

public function __construct(IndexInterface $index, array $options = []) {
  if (!$index
    ->status()) {
    $index_label = $index
      ->label();
    throw new SearchApiException("Can't search on index '{$index_label}' which is disabled.");
  }
  $this->index = $index;
  $this->results = new ResultSet($this);
  $this->options = $options;
  $this->conditionGroup = $this
    ->createConditionGroup('AND');
}