| 1 |
<?php |
<?php |
| 2 |
// $Id: apachesolr.module,v 1.1.2.12.2.161.2.7 2009/10/23 12:18:03 claudiucristea Exp $ |
// $Id: apachesolr.module,v 1.1.2.12.2.161.2.8 2009/11/05 17:24:43 claudiucristea Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 279 |
* Truncate and rebuild the apachesolr_search_node table, reset the apachesolr_index_last variable. |
* Truncate and rebuild the apachesolr_search_node table, reset the apachesolr_index_last variable. |
| 280 |
* This is the most complete way to force reindexing, or to build the indexing table for the |
* This is the most complete way to force reindexing, or to build the indexing table for the |
| 281 |
* first time. |
* first time. |
| 282 |
|
* |
| 283 |
|
* @param $type |
| 284 |
|
* A single content type to be reindexed, leaving the others unaltered. |
| 285 |
*/ |
*/ |
| 286 |
function apachesolr_rebuild_index_table() { |
function apachesolr_rebuild_index_table($type = NULL) { |
| 287 |
db_query("DELETE FROM {apachesolr_search_node}"); |
if (isset($type)) { |
| 288 |
// Populate table |
db_query("DELETE FROM {apachesolr_search_node} WHERE nid IN (SELECT nid FROM {node} WHERE type = '%s')", $type); |
| 289 |
db_query("INSERT INTO {apachesolr_search_node} (nid, status, changed) |
// Populate table |
| 290 |
SELECT n.nid, n.status, GREATEST(n.created, n.changed, c.last_comment_timestamp) AS changed |
db_query("INSERT INTO {apachesolr_search_node} (nid, status, changed) |
| 291 |
FROM {node} n |
SELECT n.nid, n.status, %d AS changed |
| 292 |
LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid"); |
FROM {node} n WHERE n.type = '%s'", time(), $type); |
| 293 |
// Make sure no nodes end up with a timestamp that's in the future. |
} |
| 294 |
$time = time(); |
else { |
| 295 |
db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE changed > %d", $time, $time); |
db_query("DELETE FROM {apachesolr_search_node}"); |
| 296 |
apachesolr_clear_last_index(); |
// Populate table |
| 297 |
|
db_query("INSERT INTO {apachesolr_search_node} (nid, status, changed) |
| 298 |
|
SELECT n.nid, n.status, GREATEST(n.created, n.changed, c.last_comment_timestamp) AS changed |
| 299 |
|
FROM {node} n |
| 300 |
|
LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid"); |
| 301 |
|
// Make sure no nodes end up with a timestamp that's in the future. |
| 302 |
|
$time = time(); |
| 303 |
|
db_query("UPDATE {apachesolr_search_node} SET changed = %d WHERE changed > %d", $time, $time); |
| 304 |
|
apachesolr_clear_last_index(); |
| 305 |
|
} |
| 306 |
} |
} |
| 307 |
|
|
| 308 |
function _apachesolr_exclude_types($namespace) { |
function _apachesolr_exclude_types($namespace) { |