You are here

public function Index::query in Search API 8

Creates a query object for this index.

Parameters

array $options: (optional) Associative array of options configuring this query.

Return value

\Drupal\search_api\Query\QueryInterface A query object for searching this index.

Throws

\Drupal\search_api\SearchApiException Thrown if the index is currently disabled or its server doesn't exist.

Overrides IndexInterface::query

See also

\Drupal\search_api\Query\QueryInterface::create()

File

src/Entity/Index.php, line 1211

Class

Index
Defines the search index configuration entity.

Namespace

Drupal\search_api\Entity

Code

public function query(array $options = []) {
  if (!$this
    ->status()) {
    throw new SearchApiException('Cannot search on a disabled index.');
  }
  return \Drupal::getContainer()
    ->get('search_api.query_helper')
    ->createQuery($this, $options);
}