You are here

protected function SearchApiTokenizer::processFieldValue in Search API 7

Called for processing a single text element in a field. The default implementation just calls process().

$value can either be left a string, or changed into an array of tokens. A token is an associative array containing:

  • value: Either the text inside the token, or a nested array of tokens. The score of nested tokens will be multiplied by their parent's score.
  • score: The relative importance of the token, as a float, with 1 being the default.

Overrides SearchApiAbstractProcessor::processFieldValue

File

includes/processor_tokenizer.inc, line 78
Contains SearchApiTokenizer.

Class

SearchApiTokenizer
Processor for tokenizing fulltext data by replacing (configurable) non-letters with spaces.

Code

protected function processFieldValue(&$value) {
  $this
    ->prepare();
  if ($this->ignorable) {
    $value = preg_replace('/(' . $this->ignorable . ')+/u', '', $value);
  }
  if ($this->spaces) {
    $arr = preg_split('/(' . $this->spaces . ')+/u', $value);
    if (count($arr) > 1) {
      $value = array();
      foreach ($arr as $token) {
        $value[] = array(
          'value' => $token,
        );
      }
    }
  }
}