public function SnowballStemmer::preprocessSearchQuery in Snowball Stemmer 8
Same name and namespace in other branches
- 2.x src/Plugin/search_api/processor/SnowballStemmer.php \Drupal\snowball_stemmer\Plugin\search_api\processor\SnowballStemmer::preprocessSearchQuery()
Preprocesses a search query.
Parameters
\Drupal\search_api\Query\QueryInterface $query: The object representing the query to be executed.
Overrides Stemmer::preprocessSearchQuery
File
- src/
Plugin/ search_api/ processor/ SnowballStemmer.php, line 121
Class
- SnowballStemmer
- Stems search terms.
Namespace
Drupal\snowball_stemmer\Plugin\search_api\processorCode
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());
}