You are here

public function SnowballStemmer::preprocessSearchQuery in Snowball Stemmer 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/processor/SnowballStemmer.php \Drupal\snowball_stemmer\Plugin\search_api\processor\SnowballStemmer::preprocessSearchQuery()

File

src/Plugin/search_api/processor/SnowballStemmer.php, line 121

Class

SnowballStemmer
Stems search terms.

Namespace

Drupal\snowball_stemmer\Plugin\search_api\processor

Code

public function preprocessSearchQuery(QueryInterface $query) {

  // Try the queries language, and if not fallback to the current site
  // language.
  if ($languages = $query
    ->getLanguages()) {

    // Todo: What if there is more than one language?
    $language = reset($languages);
  }
  else {
    $language = $this
      ->getLanguageManager()
      ->getCurrentLanguage()
      ->getId();
  }
  $keys =& $query
    ->getKeys();
  if (isset($keys) && $this
    ->getStemmer()
    ->setLanguage($language)) {
    $this
      ->processKeys($keys);
  }
  $conditions = $query
    ->getConditionGroup();
  $this
    ->processConditions($conditions
    ->getConditions());
}