You are here

public function SearchApiViewsQuery::init in Search API 7

Create the basic query object and fill with default values.

Overrides views_plugin_query::init

File

contrib/search_api_views/includes/query.inc, line 91
Contains SearchApiViewsQuery.

Class

SearchApiViewsQuery
Views query class using a Search API index as the data source.

Code

public function init($base_table, $base_field, $options) {
  try {
    $this->errors = array();
    parent::init($base_table, $base_field, $options);
    $this->fields = array();
    if (substr($base_table, 0, 17) == 'search_api_index_') {
      $id = substr($base_table, 17);
      $this->index = search_api_index_load($id);
      $this->query = $this->index
        ->query(array(
        'parse mode' => $this->options['parse_mode'],
      ));
    }
  } catch (Exception $e) {
    $this->errors[] = $e
      ->getMessage();
  }
}