You are here

public function Stopwords::preprocessSearchQuery in Search API 8

Preprocesses a search query.

Parameters

\Drupal\search_api\Query\QueryInterface $query: The object representing the query to be executed.

Overrides FieldsProcessorPluginBase::preprocessSearchQuery

File

src/Plugin/search_api/processor/Stopwords.php, line 107

Class

Stopwords
Allows you to define stopwords which will be ignored in searches.

Namespace

Drupal\search_api\Plugin\search_api\processor

Code

public function preprocessSearchQuery(QueryInterface $query) {
  $this->ignored = [];
  parent::preprocessSearchQuery($query);
  $results = $query
    ->getResults();
  foreach ($this->ignored as $ignored_search_key) {
    $results
      ->addIgnoredSearchKey($ignored_search_key);
  }
}