public function SearchQuery::executeFirstPass

cis7 search.extender.inc public SearchQuery::executeFirstPass()
cle7 search.extender.inc public SearchQuery::executeFirstPass()
elmsmedia7 search.extender.inc public SearchQuery::executeFirstPass()
icor7 search.extender.inc public SearchQuery::executeFirstPass()
meedjum_blog7 search.extender.inc public SearchQuery::executeFirstPass()
mooc7 search.extender.inc public SearchQuery::executeFirstPass()

Executes the first pass query.

This can either be done explicitly, so that additional scores and conditions can be applied to the second pass query, or implicitly by addScore() or execute().

Return value

TRUE if search items exist, FALSE if not.

1 call to SearchQuery::executeFirstPass()
SearchQuery::execute in modules/search/search.extender.inc
Executes the search.

File

modules/search/search.extender.inc, line 343
Search query extender and helper functions.

Class

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

Code

public function executeFirstPass() {
  $this->parseSearchExpression();

  if (count($this->words) == 0) {
    form_set_error('keys', format_plural(variable_get('minimum_word_size', 3), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
    return FALSE;
  }
  if ($this->expressionsIgnored) {
    drupal_set_message(t('Your search used too many AND/OR expressions. Only the first @count terms were included in this search.', array('@count' => variable_get('search_and_or_limit', 7))), 'warning');
  }
  $this->executedFirstPass = TRUE;

  if (!empty($this->words)) {
    $or = db_or();
    foreach ($this->words as $word) {
      $or->condition('i.word', $word);
    }
    $this->condition($or);
  }
  // Build query for keyword normalization.
  $this->join('search_total', 't', 'i.word = t.word');
  $this->condition('i.type', $this->type)->groupBy('i.type')->groupBy('i.sid')->having('COUNT(*) >= :matches', array(':matches' => $this->matches));

  // Clone the query object to do the firstPass query;
  $first = clone $this->query;

  // For complex search queries, add the LIKE conditions to the first pass query.
  if (!$this->simple) {
    $first->join('search_dataset', 'd', 'i.sid = d.sid AND i.type = d.type');
    $first->condition($this->conditions);
  }

  // Calculate maximum keyword relevance, to normalize it.
  $first->addExpression('SUM(i.score * t.count)', 'calculated_score');
  $this->normalize = $first->range(0, 1)->orderBy('calculated_score', 'DESC')->execute()->fetchField();

  if ($this->normalize) {
    return TRUE;
  }
  return FALSE;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.