function SearchQuery::parseWord

Same name in other branches
  1. 9 core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::parseWord()
  2. 8.9.x core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::parseWord()
  3. 10 core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::parseWord()
  4. 11.x core/modules/search/src/SearchQuery.php \Drupal\search\SearchQuery::parseWord()

Helper function for parseQuery().

1 call to SearchQuery::parseWord()
SearchQuery::parseSearchExpression in modules/search/search.extender.inc
Parses the search query into SQL conditions.

File

modules/search/search.extender.inc, line 325

Class

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

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 || drupal_strlen($s) >= variable_get('minimum_word_size', 3)) {
            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,
    );
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.