You are here

function search_api_query in Search API 7

Creates a search query on a specified search index.

Parameters

$id: The ID or machine name of the index to execute the search on.

$options: An associative array of options to be passed to SearchApiQueryInterface::__construct().

Return value

SearchApiQueryInterface An object for searching on the specified index.

Throws

SearchApiException If the index is unknown or disabled, or some other error was encountered.

1 call to search_api_query()
SearchApiWebTest::doSearch in ./search_api.test
Executes a search on the test index.

File

./search_api.module, line 1893
Provides a flexible framework for implementing search services.

Code

function search_api_query($id, array $options = array()) {
  $index = search_api_index_load($id);
  if (!$index) {
    throw new SearchApiException(t('Unknown index with ID @id.', array(
      '@id' => $id,
    )));
  }
  return $index
    ->query($options);
}