function apachesolr_index_node_check_table in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr.index.inc \apachesolr_index_node_check_table()
- 7 apachesolr.index.inc \apachesolr_index_node_check_table()
hook_cron() helper to try to make the index table consistent with their respective entity table.
2 string references to 'apachesolr_index_node_check_table'
- apachesolr_get_index_callbacks in ./
apachesolr.module - Return a set of callbacks for indexing a node
- hook_apachesolr_entity_info_alter in ./
apachesolr.api.php - Add information to index other entities. There are some modules in http://drupal.org that can give a good example of custom entity indexing such as apachesolr_user, apachesolr_term
File
- ./
apachesolr.index.inc, line 1239 - Functions related to Apache Solr indexing operations.
Code
function apachesolr_index_node_check_table() {
// Check for unpublished content that wasn't deleted from the index.
$table = apachesolr_get_indexer_table('node');
// We do not check more nodes than double the cron limit per time
// Update or delete at most this many in each Solr query.
$limit = variable_get('apachesolr_cron_mass_limit', 500);
$result = db_query("SELECT n.nid, n.status FROM {{$table}} aien INNER JOIN {node} n ON n.nid = aien.entity_id WHERE aien.status <> n.status LIMIT 0, %d", array(
$limit * 2,
));
$nodes = array();
while ($record = db_fetch_array($result)) {
$nodes[$record['nid']] = $record;
}
$node_lists = array_chunk($nodes, $limit, TRUE);
foreach ($node_lists as $nodes) {
watchdog('Apache Solr', 'On cron running apachesolr_nodeapi_mass_update() on nids @nids', array(
'@nids' => implode(',', array_keys($nodes)),
), WATCHDOG_NOTICE);
if (!apachesolr_index_nodeapi_mass_update($nodes, $table)) {
// Solr query failed - so stop trying.
break;
}
}
// Check for deleted content that wasn't deleted from the index.
$result = db_query("SELECT aien.entity_id AS nid FROM {{$table}} aien LEFT JOIN {node} n ON n.nid = aien.entity_id WHERE n.nid = NULL LIMIT 0, %d", array(
$limit * 2,
));
$nodes = array();
while ($record = db_fetch_array($result)) {
$nodes[$record['nid']] = $record;
}
$node_lists = array_chunk($nodes, $limit, TRUE);
foreach ($node_lists as $nodes) {
watchdog('Apache Solr', 'On cron running apachesolr_nodeapi_mass_delete() on nids @nids', array(
'@nids' => implode(',', array_keys($nodes)),
), WATCHDOG_WARNING);
if (!apachesolr_index_nodeapi_mass_delete($nodes, $table)) {
// Solr query failed - so stop trying.
break;
}
}
}