You are here

function apachesolr_attachments_update_index in Apache Solr Attachments 6.2

Same name and namespace in other branches
  1. 5 apachesolr_attachments.module \apachesolr_attachments_update_index()
  2. 6 apachesolr_attachments.module \apachesolr_attachments_update_index()

Hook is called by search.module to add things to the search index. In our case we will search content types and add any CCK type that is a file type that we know how to parse and any uploaded file attachments.

File

./apachesolr_attachments.module, line 129
Provides a file attachment search implementation for use with the Apache Solr module

Code

function apachesolr_attachments_update_index() {
  if (!variable_get('apachesolr_attachments_tika_path', '') && variable_get('apachesolr_attachment_extract_using', 'tika') == 'tika') {
    return;
  }
  $start = time();
  $cron_try = variable_get('apachesolr_attachements_cron_try', 20);
  $cron_limit = variable_get('apachesolr_attachments_cron_limit', 100);
  $cron_time_limit = variable_get('apachesolr_attachements_cron_time_limit', 15);
  $num_tried = 0;
  module_load_include('inc', 'apachesolr_attachments', 'apachesolr_attachments.admin');
  do {
    $rows = apachesolr_get_nodes_to_index('apachesolr_attachments', $cron_try);
    $success = apachesolr_index_nodes($rows, 'apachesolr_attachments');
    $num_tried += $cron_try;
  } while ($success && $num_tried < $cron_limit && time() - $start < $cron_time_limit);
}