You are here

public function SearchApiStopWords::process in Search API 7

Function that is ultimately called for all text by the standard implementation, and does nothing by default.

Parameters

$value: The value to preprocess as a string. Can be manipulated directly, nothing has to be returned. Since this can be called for all value types, $value has to remain a string.

Overrides SearchApiAbstractProcessor::process

File

includes/processor_stopwords.inc, line 57
Contains SearchApiStopWords.

Class

SearchApiStopWords
Processor for removing stopwords from index and search terms.

Code

public function process(&$value) {
  $stopwords = $this
    ->getStopWords();
  if (empty($stopwords) || !is_string($value)) {
    return;
  }
  $words = preg_split('/\\s+/', $value);
  foreach ($words as $sub_key => $sub_value) {
    if (isset($stopwords[$sub_value])) {
      unset($words[$sub_key]);
      $this->ignored[] = $sub_value;
    }
  }
  $value = implode(' ', $words);
}