/** * Clear the Solr index. */ public function tearDown() { try { SolrSearch_Helpers_Index::deleteAll(); } catch (Exception $e) { } parent::tearDown(); }
/** * Pass setting to Solr search * * @param int $offset Results offset * @param int $limit Limit per page * @return SolrResultDoc Solr results */ protected function _search($offset, $limit, $limitToPublicItems = true) { // Connect to Solr. $solr = SolrSearch_Helpers_Index::connect(); // Get the parameters. $params = $this->_getParameters(); // Construct the query. $query = $this->_getQuery($limitToPublicItems); // Execute the query. return $solr->search($query, $offset, $limit, $params); }
/** * Display the "Server Configuration" form. */ public function serverAction() { $form = new SolrSearch_Form_Server(); // If a valid form was submitted. if ($this->_request->isPost() && $form->isValid($_POST)) { // Set the options. foreach ($form->getValues() as $option => $value) { set_option($option, $value); } } // Are the current parameters valid? if (SolrSearch_Helpers_Index::pingSolrServer()) { // Notify valid connection. $this->_helper->flashMessenger(__('Solr connection is valid.'), 'success'); } else { $this->_helper->flashMessenger(__('Solr connection is invalid.'), 'error'); } $this->view->form = $form; }
/** * When an item is deleted, clear its Solr record. * * @param array $args With `record`. */ public function hookBeforeDeleteItem($args) { $item = $args['record']; $solr = SolrSearch_Helpers_Index::connect(); try { $solr->deleteById('Item_' . $item['id']); $solr->commit(); $solr->optimize(); } catch (Exception $e) { } }
/** * Reindex all records. */ public function perform() { SolrSearch_Helpers_Index::deleteAll(); SolrSearch_Helpers_Index::indexAll(); }
/** * Get the URL for the record that corresponds to a Solr document. * * @param Apache_Solr_Document $doc A Solr document. * * @return string The record URL. */ public static function getDocumentUrl($doc) { $record = get_db()->getTable($doc->model)->find($doc->modelid); return SolrSearch_Helpers_Index::getUri($record); }