function SearchQuery::parseWord
Parses a word or phrase for parseQuery().
Splits a phrase into words. Adds its words to $this->words, if it is not already there. Returns a list containing the number of new words found, and the total number of words in the phrase.
1 call to SearchQuery::parseWord()
- SearchQuery::parseSearchExpression in core/
modules/ search/ src/ SearchQuery.php  - Parses the search query into SQL conditions.
 
File
- 
              core/
modules/ search/ src/ SearchQuery.php, line 360  
Class
- SearchQuery
 - Search query extender and helper functions.
 
Namespace
Drupal\searchCode
protected function parseWord($word) {
  $num_new_scores = 0;
  $num_valid_words = 0;
  // Determine the scorewords of this word/phrase.
  $split = explode(' ', $word);
  foreach ($split as $s) {
    $num = is_numeric($s);
    if ($num || mb_strlen($s) >= \Drupal::config('search.settings')->get('index.minimum_word_size')) {
      if (!isset($this->words[$s])) {
        $this->words[$s] = $s;
        $num_new_scores++;
      }
      $num_valid_words++;
    }
  }
  // Return matching snippet and number of added words.
  return [
    $num_new_scores,
    $num_valid_words,
  ];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.