diff --git a/controllers/AdminController.php b/controllers/AdminController.php index b7630c96..b746ff9c 100644 --- a/controllers/AdminController.php +++ b/controllers/AdminController.php @@ -225,10 +225,12 @@ public function reindexAction() if ($this->_request->isPost()) { try { + $clear = $this->getRequest()->getParam('clear') ? true : false; // Clear and reindex. Zend_Registry::get('job_dispatcher')->sendLongRunning( - 'SolrSearch_Job_Reindex' + 'SolrSearch_Job_Reindex', + array('clear' => $clear) ); // Flash success. diff --git a/forms/SolrSearch_Form_Reindex.php b/forms/SolrSearch_Form_Reindex.php index 0c9648c4..e21c15a1 100644 --- a/forms/SolrSearch_Form_Reindex.php +++ b/forms/SolrSearch_Form_Reindex.php @@ -19,10 +19,17 @@ public function init() parent::init(); + $this->addElement('checkbox', 'clear', array( + 'label' => __('Clear index'), + )); + $this->addElement('submit', 'submit', array( - 'label' => __('Clear and Reindex') + 'label' => __('Reindex') )); + $this->addDisplayGroup(array('clear'), 'fields'); + $this->addDisplayGroup(array('submit'), 'submit_button'); + } diff --git a/jobs/SolrSearch_Job_Reindex.php b/jobs/SolrSearch_Job_Reindex.php index 7e5f2092..fcd47d23 100644 --- a/jobs/SolrSearch_Job_Reindex.php +++ b/jobs/SolrSearch_Job_Reindex.php @@ -17,7 +17,10 @@ class SolrSearch_Job_Reindex extends Omeka_Job_AbstractJob */ public function perform() { - SolrSearch_Helpers_Index::deleteAll(); + if (isset($this->_options['clear']) && $this->_options['clear']) { + SolrSearch_Helpers_Index::deleteAll(); + } + SolrSearch_Helpers_Index::indexAll(); }