/** * Debug method to allow manual reindexing with output via the URL * /Lucene/reindex * * @access public * Note that this should NOT be used as a reindexing * process in production, as it doesn't allow for out of memory or script * execution time problems. */ public function reindex() { set_time_limit(600); $start = microtime(true); echo '<h1>Reindexing</h1>' . "\n"; flush(); echo 'Note that this process may die due to time limit or memory ' . 'exhaustion, and is purely for debugging purposes. Use the ' . 'Queued Jobs reindex process for production indexing.' . "<br />\n<br />\n"; flush(); ZendSearchLuceneWrapper::getIndex(true); $indexable = ZendSearchLuceneWrapper::getAllIndexableObjects(); foreach ($indexable as $item) { $obj = DataObject::get_by_id($item[0], $item[1]); if ($obj) { $obj_start = microtime(true); echo $item[0] . ' ' . $item[1] . ' (' . $obj->class . ')'; flush(); ZendSearchLuceneWrapper::index($obj); echo ' - ' . round(microtime(true) - $obj_start, 3) . ' seconds' . "<br />\n"; flush(); } else { echo 'Object ' . $item[0] . ' ' . $item[1] . ' was not found.' . "<br />\n"; flush(); } } echo "<br />\n" . 'Finished (' . round(microtime(true) - $start, 3) . ' seconds)' . "<br />\n"; flush(); }
public function setup() { // Wipe current index ZendSearchLuceneWrapper::getIndex(true); $indexed = ZendSearchLuceneWrapper::getAllIndexableObjects(); $this->remainingDocuments = $indexed; $this->totalSteps = count($indexed); }
public function setup() { // Wipe current index ZendSearchLuceneWrapper::getIndex(true); $this->jobData = ZendSearchLuceneWrapper::getAllIndexableObjects(); $this->totalSteps = count($this->jobData); $this->currentStep = 0; }
/** * Indexes the object after it has been written to the database. */ public function onAfterWrite() { // Obey index filter rules $objs = ZendSearchLuceneWrapper::getAllIndexableObjects($this->owner->ClassName); ZendSearchLuceneWrapper::delete($this->owner); foreach ($objs as $obj) { if (!is_object($obj)) { continue; } if (!is_object($this->owner)) { continue; } if ($obj[0] == $this->owner->class && $obj[1] == $this->owner->ID) { ZendSearchLuceneWrapper::index($this->owner); } } parent::onAfterWrite(); }