You are here

function search_files_update_totals in Search Files 7.2

Same name and namespace in other branches
  1. 6.2 search_files.module \search_files_update_totals()

Updates the search totals for a given search type.

Marks all words in the search index for the given type as "dirty", meaning their search totals should be rebuilt, and then causes the totals to be rebuilt.

NOTE TO MAINTAINER OF THIS MODULE: You should not need to call the search_dirty() part of this function, because search_index() calls search_dirty() on all indexed content! But I've left it as-is for now... Probably you should just call search_update_totals().

Parameters

$type: The search type (search module) to update.

2 calls to search_files_update_totals()
search_files_attachments_update_index in ./search_files_attachments.module
Implements hook_update_index().
search_files_directories_update_index in ./search_files_directories.module
Implements hook_update_index().

File

./search_files.module, line 559
Organizes and provides helper functions for extracting text from files.

Code

function search_files_update_totals($type) {
  $result = db_query("SELECT data FROM {search_dataset} WHERE type = :type", array(
    ':type' => $type,
  ))
    ->fetchAll();
  foreach ($result as $item) {
    foreach (explode(" ", $item->data) as $word) {
      search_dirty($word);
    }
  }
  search_update_totals();
}