| 1 |
<?php |
<?php |
| 2 |
// $Id: xapian.install,v 1.4 2008/06/18 22:05:06 jeremy Exp $ |
// $Id: xapian.install,v 1.4.2.2 2008/11/17 05:24:45 simon Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* Installation file for xapian search library as a drupal module |
* Installation file for xapian search library as a drupal module |
| 7 |
* |
* |
| 8 |
* Initial Development and sample view code by Lachlan Gunn |
* Initial Development and sample view code by Lachlan Gunn |
| 9 |
* http://drupal.org/user/277696 |
* http://drupal.org/user/277696 |
| 10 |
* Core patch, tighter drupal integration, adherance to drupal standards, |
* Core patch, tighter drupal integration, adherance to drupal standards, |
| 11 |
* making ready for release by Simon Lindsay |
* making ready for release by Simon Lindsay |
| 30 |
'fields' => array( |
'fields' => array( |
| 31 |
'xid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'), |
'xid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '11'), |
| 32 |
'added' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), |
'added' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), |
| 33 |
|
'indexed' => array('type' => 'int', 'not null' => TRUE, 'default' => 0), |
| 34 |
'priority' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '11'), |
'priority' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '11'), |
| 35 |
'status' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '1'), |
'status' => array('type' => 'int', 'not null' => FALSE, 'default' => 0, 'disp-width' => '1'), |
| 36 |
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')), |
'nid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11')), |
| 37 |
'primary key' => array('xid'), |
'primary key' => array('xid'), |
| 38 |
'indexes' => array( |
'indexes' => array( |
| 39 |
'nid' => array('nid', 'status')), |
'nid' => array('nid', 'status', 'indexed')), |
| 40 |
); |
); |
| 41 |
|
|
| 42 |
return $schema; |
return $schema; |
| 59 |
variable_del('xapian_indexing_throttle'); |
variable_del('xapian_indexing_throttle'); |
| 60 |
variable_del('xapian_search_results_per_page'); |
variable_del('xapian_search_results_per_page'); |
| 61 |
} |
} |
| 62 |
|
|
| 63 |
|
/** |
| 64 |
|
* Add 'indexed' column for tracking when content was last indexed. This allows |
| 65 |
|
* us to isolate exactly which item fails on if we hit a redirect or run out of |
| 66 |
|
* memory. |
| 67 |
|
* Also, remove unpublished content from xapian indexes. |
| 68 |
|
*/ |
| 69 |
|
function xapian_update_6001() { |
| 70 |
|
$ret = array(); |
| 71 |
|
|
| 72 |
|
db_add_field($ret, 'xapian_index_queue', 'indexed', |
| 73 |
|
array( |
| 74 |
|
'type' => 'varchar', |
| 75 |
|
'length' => 32, |
| 76 |
|
'not null' => TRUE, |
| 77 |
|
'default' => '', |
| 78 |
|
'description' => 'Track when content was last indexed.', |
| 79 |
|
), |
| 80 |
|
array('indexes' => |
| 81 |
|
array( |
| 82 |
|
'indexed' => array('indexed'), |
| 83 |
|
), |
| 84 |
|
) |
| 85 |
|
); |
| 86 |
|
|
| 87 |
|
$result = db_query('SELECT nid FROM {node} WHERE status != 1'); |
| 88 |
|
while ($unpublished = db_fetch_object($result)) { |
| 89 |
|
xapian_remove_node_from_index($unpublished); |
| 90 |
|
$ret[] = array('success' => TRUE, 'query' => t('Un-indexed unpublished node with nid !nid.', array('!nid' => $unpublished->nid))); |
| 91 |
|
} |
| 92 |
|
|
| 93 |
|
return $ret; |
| 94 |
|
} |