search_update_totals

function search_update_totals

search_update_totals()

Updates the {search_total} database table.

This function is called on shutdown to ensure that {search_total} is always up to date (even if cron times out or otherwise fails).

File

core/modules/search/search.module, line 205
Enables site-wide keyword searching.

Code

function search_update_totals() {
  // Update word IDF (Inverse Document Frequency) counts for new/changed words.
  foreach (search_dirty() as $word => $dummy) {
    // Get total count
    $total = db_query("SELECT SUM(score) FROM {search_index} WHERE word = :word", array(':word' => $word), array('target' => 'replica'))->fetchField();
    // Apply Zipf's law to equalize the probability distribution.
    $total = log10(1 + 1 / (m