You are here

public function Page::createQuery in Search API Autocomplete 8

Creates a search query based on this search.

Parameters

string $keys: The keywords to set on the query, if possible. Otherwise, this parameter can also be ignored.

array $data: (optional) Additional data passed to the callback.

Return value

\Drupal\search_api\Query\QueryInterface The created query.

Throws

\Drupal\search_api_autocomplete\SearchApiAutocompleteException Thrown if the query couldn't be created.

Overrides SearchPluginInterface::createQuery

File

src/Plugin/search_api_autocomplete/search/Page.php, line 97

Class

Page
Provides autocomplete support for the search_api_page module.

Namespace

Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\search

Code

public function createQuery($keys, array $data = []) {
  $query = $this
    ->getQueryHelper()
    ->createQuery($this
    ->getIndex());
  $query
    ->keys($keys);
  $page = $this
    ->getPage();
  if ($page && $page
    ->getSearchedFields()) {
    $query
      ->setFulltextFields(array_values($page
      ->getSearchedFields()));
  }
  return $query;
}