You are here

protected function SearchQuery::parseWord in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/search/src/SearchQuery.php \Drupal\search\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 363
Contains \Drupal\search\SearchQuery.

Class

SearchQuery
Performs a query on the full-text search index for a word or words.

Namespace

Drupal\search

Code

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 || Unicode::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 array(
    $num_new_scores,
    $num_valid_words,
  );
}