protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     $databaseManager = new sfDatabaseManager($this->configuration);
     $connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     // need a scriptname otherwise it uses the symfony file
     if ($arguments['env'] != 'prod') {
         $_SERVER['SCRIPT_NAME'] = '/' . $arguments['application'] . '_' . $arguments['env'] . '.php';
     } else {
         $_SERVER['SCRIPT_NAME'] = '/index.php';
     }
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $arguments['env'], true));
     $searchIndex = new zsSearchIndex($arguments['index']);
     //optimize to increase speed
     $searchIndex->optimize();
     //loop thru all models specified in this index and update all entries
     foreach ($searchIndex->getModels() as $model => $config) {
         $this->logSection('update', 'model: ' . $model);
         foreach (Doctrine::getTable($model)->findAll() as $object) {
             $searchIndex->updateIndex($object);
             echo '.';
         }
         echo "\n";
     }
     //re-optimize index
     $searchIndex->optimize();
 }
 public function postDelete(Doctrine_Event $event)
 {
     //if called from task do nothing
     if (!sfContext::hasInstance()) {
         return;
     }
     //delete from index
     $searchIndex = new zsSearchIndex($this->_options['index']);
     $searchIndex->updateIndex($event->getInvoker(), true);
 }
 protected function execute($arguments = array(), $options = array())
 {
     // initialize the database connection
     //$databaseManager = new sfDatabaseManager($this->configuration);
     //$connection = $databaseManager->getDatabase($options['connection'])->getConnection();
     sfContext::createInstance(sfProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true));
     $searchIndex = new zsSearchIndex($arguments['index']);
     //optimize to increase speed
     $searchIndex->optimize();
 }
Esempio n. 4
0
 /**
  * Performs a search of the specified index (null for default)
  *
  * @param string $query the search query
  * @param string $index the specifed index
  * @return array Zend_Search_Lucene_Search_QueryHit
  */
 public static function search($query, $index = null)
 {
     $search = new zsSearchIndex($index);
     return $search->search($query);
 }