Example #1
0
 /**
  * Build the post search index
  * 
  * @param boolean $isCount
  * @return boolean
  */
 protected function buildPostSearch($isCount = false)
 {
     $index = Zend_Search_Lucene::create(Zend_Registry::getInstance()->config->search->post);
     require_once 'Ifphp/models/Posts.php';
     require_once 'Ifphp/models/Feeds.php';
     require_once 'Ifphp/models/Categories.php';
     $posts = new Posts();
     $allPosts = $posts->getRecent(1, 0);
     if ($isCount) {
         echo $allPosts->count() . ' posts would have been added to the post index';
         exit;
     }
     foreach ($allPosts as $post) {
         $feed = $post->findParentFeeds();
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Text('pid', $post->id));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', $post->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('siteUrl', $post->siteUrl));
         $doc->addField(Zend_Search_Lucene_Field::Text('link', $post->link));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedTitle', $feed->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedSlug', $feed->slug));
         $doc->addField(Zend_Search_Lucene_Field::Text('feedDescription', $feed->description));
         $doc->addField(Zend_Search_Lucene_Field::keyword('category', $feed->findParentCategories()->title));
         $doc->addField(Zend_Search_Lucene_Field::Text('description', $post->description));
         $doc->addField(Zend_Search_Lucene_Field::unIndexed('publishDate', $post->publishDate));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('type', 'post'));
         $index->addDocument($doc);
     }
     chown(Zend_Registry::getInstance()->search['post'], 'www-data');
     return true;
 }
Example #2
0
 /**
  * Returns Zend_Search_Lucene instance for given subroot
  *
  * every subroot has it's own instance
  *
  * @param Kwf_Component_Data for this index
  * @return Zend_Search_Lucene_Interface
  */
 public static function getInstance(Kwf_Component_Data $subroot)
 {
     while ($subroot) {
         if (Kwc_Abstract::getFlag($subroot->componentClass, 'subroot')) {
             break;
         }
         $subroot = $subroot->parent;
     }
     if (!$subroot) {
         $subroot = Kwf_Component_Data_Root::getInstance();
     }
     static $instance = array();
     if (!isset($instance[$subroot->componentId])) {
         $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
         $analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_ShortWords(2));
         //$stopWords = explode(' ', 'der dir das einer eine ein und oder doch ist sind an in vor nicht wir ihr sie es ich');
         //$analyzer->addFilter(new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords));
         Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
         Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8');
         Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0666);
         $path = 'cache/fulltext';
         $path .= '/' . $subroot->componentId;
         try {
             $instance[$subroot->componentId] = Zend_Search_Lucene::open($path);
         } catch (Zend_Search_Lucene_Exception $e) {
             $instance[$subroot->componentId] = Zend_Search_Lucene::create($path);
         }
     }
     return $instance[$subroot->componentId];
 }
Example #3
0
 public function buildplaces()
 {
     ini_set('memory_limit', '1000M');
     set_time_limit(0);
     $time = time();
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
     /**
      * Create index
      */
     $index = Zend_Search_Lucene::create($this->_indexPath);
     /**
      * Get all users
      */
     $sql = $this->_db->select()->from($this->_name, array('id', 'name', 'placepic'))->limit(7500);
     $result = $this->_db->fetchAssoc($sql);
     foreach ($result as $values) {
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::keyword('placeid', $values['id']));
         $doc->addField(Zend_Search_Lucene_Field::text('placename', $values['name']));
         $doc->addField(Zend_Search_Lucene_Field::unStored('placepic', $values['placepic']));
         $index->addDocument($doc);
     }
     $index->commit();
     $elapsed = time() - $time;
     print_r($elapsed);
 }
Example #4
0
 private function getLucene()
 {
     if ($this->lucene) {
         return $this->lucene;
     }
     try {
         $this->lucene = Zend_Search_Lucene::open($this->directory);
     } catch (Zend_Search_Lucene_Exception $e) {
         $this->lucene = Zend_Search_Lucene::create($this->directory);
     }
     global $prefs;
     if (!empty($prefs['unified_lucene_max_buffered_docs'])) {
         // these break indexing if set empty
         $this->lucene->setMaxBufferedDocs($prefs['unified_lucene_max_buffered_docs']);
         // default is 10
     }
     if (!empty($prefs['unified_lucene_max_merge_docs'])) {
         $this->lucene->setMaxMergeDocs($prefs['unified_lucene_max_merge_docs']);
         // default is PHP_INT_MAX (effectively "infinite")
     }
     if (!empty($prefs['unified_lucene_merge_factor'])) {
         $this->lucene->setMergeFactor($prefs['unified_lucene_merge_factor']);
         // default is 10
     }
     $this->lucene->setResultSetLimit($this->resultSetLimit);
     return $this->lucene;
 }
Example #5
0
 /**
  * Creates a new ZendLucene handler connection
  *
  * @param string $location
  */
 public function __construct($location)
 {
     /**
      * We're using realpath here because Zend_Search_Lucene does not do
      * that itself. It can cause issues because their destructor uses the
      * same filename but the cwd could have been changed.
      */
     $location = realpath($location);
     /* If the $location doesn't exist, ZSL throws a *generic* exception. We
      * don't care here though and just always assume it is because the
      * index does not exist. If it doesn't exist, we create it.
      */
     try {
         $this->connection = Zend_Search_Lucene::open($location);
     } catch (Zend_Search_Lucene_Exception $e) {
         $this->connection = Zend_Search_Lucene::create($location);
     }
     $this->inTransaction = 0;
     if (!$this->connection) {
         throw new ezcSearchCanNotConnectException('zendlucene', $location);
     }
     // Set proper default encoding for query parser
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
 }
 public function updateAction()
 {
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
     // Создание индекса
     $index = Zend_Search_Lucene::create(APPLICATION_ROOT . '/data/my-index');
     $mediaMapper = new Media_Model_Mapper_Media();
     $select = $mediaMapper->getDbTable()->select();
     $select->where('deleted != ?', 1)->where('active != ?', 0)->where('category_id IN(?)', array(2, 3, 4))->order('timestamp DESC');
     $mediaItems = $mediaMapper->fetchAll($select);
     if (!empty($mediaItems)) {
         foreach ($mediaItems as $mediaItem) {
             $doc = new Zend_Search_Lucene_Document();
             // Сохранение Name документа для того, чтобы идентифицировать его
             // в результатах поиска
             $doc->addField(Zend_Search_Lucene_Field::Text('title', strtolower($mediaItem->getName()), 'UTF-8'));
             // Сохранение URL документа для того, чтобы идентифицировать его
             // в результатах поиска
             $doc->addField(Zend_Search_Lucene_Field::Text('url', '/media/' . $mediaItem->getFullPath(), 'UTF-8'));
             // Сохранение Description документа для того, чтобы идентифицировать его
             // в результатах поиска
             // $doc->addField(Zend_Search_Lucene_Field::Text('description', strtolower($mediaItem->getSContent()),'UTF-8'));
             // Индексирование keyWords содержимого документа
             $doc->addField(Zend_Search_Lucene_Field::UnStored('keyword', strtolower($mediaItem->getMetaKeywords()), 'UTF-8'));
             // Индексирование содержимого документа
             $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', strtolower($mediaItem->getContent()), 'UTF-8'));
             // Добавление документа в индекс
             $index->addDocument($doc);
         }
     }
 }
Example #7
0
 public function buildAction()
 {
     // create the index
     $index = Zend_Search_Lucene::create(APPLICATION_PATH . '/indexes');
     // fetch all of the current pages
     $mdlPage = new Model_Page();
     $currentPages = $mdlPage->fetchAll();
     if ($currentPages->count() > 0) {
         // create a new search document for each page
         foreach ($currentPages as $p) {
             $page = new CMS_Content_Item_Page($p->id);
             $doc = new Zend_Search_Lucene_Document();
             // you use an unindexed field for the id because you want the id to be
             // included in the search results but not searchable
             $doc->addField(Zend_Search_Lucene_Field::unIndexed('page_id', $page->id));
             // you use text fields here because you want the content to be searchable
             // and to be returned in search results
             $doc->addField(Zend_Search_Lucene_Field::text('page_name', $page->name));
             $doc->addField(Zend_Search_Lucene_Field::text('page_headline', $page->headline));
             $doc->addField(Zend_Search_Lucene_Field::text('page_description', $page->description));
             $doc->addField(Zend_Search_Lucene_Field::text('page_content', $page->content));
             // add the document to the index
             $index->addDocument($doc);
         }
     }
     // optimize the index
     $index->optimize();
     // pass the view data for reporting
     $this->view->indexSize = $index->numDocs();
 }
Example #8
0
 public function luceneIndexAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $path = PUBLIC_PATH . '/tmp/lucene';
     try {
         $index = Zend_Search_Lucene::open($path);
     } catch (Zend_Search_Lucene_Exception $e) {
         try {
             $index = Zend_Search_Lucene::create($path);
         } catch (Zend_Search_Lucene_Exception $e) {
             echo "Unable to open or create index : {$e->getMessage()}";
         }
     }
     for ($i = 0; $i < $index->maxDoc(); $i++) {
         $index->delete($i);
     }
     $users = new Application_Model_User();
     $users = $users->fetchAll();
     foreach ($users as $_user) {
         Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Text('title', $_user->getFirstName()));
         $doc->addField(Zend_Search_Lucene_Field::keyword('empcode', $_user->getEmployeeCode()));
         $index->addDocument($doc);
         $index->commit();
         $index->optimize();
     }
 }
Example #9
0
 /**
  * Creates a new Lucene index.
  * 
  * @param	string	name
  * @param	array	fields
  * @return	Lucene
  */
 public static function create($name, $fields)
 {
     $luceneID = self::insert($name);
     $luceneObj = new Lucene($luceneID);
     $luceneObj->getEditor()->addField($fields);
     Zend_Search_Lucene::create(LW_DIR . 'lucene/' . $name);
     return $luceneObj;
 }
Example #10
0
 public static function getLuceneIndex()
 {
     ProjectConfiguration::registerZend();
     if (file_exists($index = self::getLuceneIndexFile())) {
         return Zend_Search_Lucene::open($index);
     }
     return Zend_Search_Lucene::create($index);
 }
Example #11
0
 /**
  * Creates a new ZendLucene handler connection
  *
  * @param string $location
  */
 public function __construct($location)
 {
     $this->connection = Zend_Search_Lucene::create($location);
     $this->inTransaction = 0;
     if (!$this->connection) {
         throw new ezcSearchCanNotConnectException('zendlucene', $location);
     }
 }
 public function indexAction()
 {
     if (is_file(TEMP_PATH . '/Search/write.lock.file')) {
         $_indexHandle = Zend_Search_Lucene::open(TEMP_PATH . '/Search');
     } else {
         $_indexHandle = Zend_Search_Lucene::create(TEMP_PATH . '/Search');
     }
     $this->view->count = intval($_indexHandle->maxDoc());
 }
 public function init()
 {
     if (is_file(TEMP_PATH . '/Search/write.lock.file')) {
         $this->_indexHandle = Zend_Search_Lucene::open(TEMP_PATH . '/Search');
     } else {
         $this->_indexHandle = Zend_Search_Lucene::create(TEMP_PATH . '/Search');
     }
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
 }
Example #14
0
 public static function buildIndex()
 {
     Zend_Registry::get('LOG')->log("--------------------------------", Zend_Log::NOTICE);
     Zend_Registry::get('LOG')->log("", Zend_Log::NOTICE);
     $articles_index = Uni_Search::articlesIndex();
     if (!file_exists($articles_index)) {
         Zend_Registry::get('LOG')->log("Creating index: {$articles_index}", Zend_Log::NOTICE);
         $index = Zend_Search_Lucene::create($articles_index);
     } else {
         Zend_Registry::get('LOG')->log("Updating index: {$articles_index}", Zend_Log::NOTICE);
         $index = Zend_Search_Lucene::open($articles_index);
         // Clear index
         Zend_Registry::get('LOG')->log("Clearing index", Zend_Log::NOTICE);
         $pattern = new Zend_Search_Lucene_Index_Term('*', 'title');
         $query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
         $hits = $index->find($query);
         foreach ($hits as $hit) {
             $index->delete($hit->id);
         }
     }
     Zend_Registry::get('LOG')->log("Loading Articles", Zend_Log::NOTICE);
     $table = Zend_Registry::get('DOCTRINE_CONNECTION')->getTable('Article');
     $articles = $table->findAll();
     foreach ($articles as $article) {
         Zend_Registry::get('LOG')->log("  Adding article to index: {$article->title}", Zend_Log::NOTICE);
         $doc = Uni_Search::createDocFromArticle($article);
         $index->addDocument($doc);
     }
     Zend_Registry::get('LOG')->log("", Zend_Log::NOTICE);
     Zend_Registry::get('LOG')->log("--------------------------------", Zend_Log::NOTICE);
     $tips_index = Uni_Search::tipsIndex();
     if (!file_exists($tips_index)) {
         Zend_Registry::get('LOG')->log("Creating index: {$tips_index}", Zend_Log::NOTICE);
         $index = Zend_Search_Lucene::create($tips_index);
     } else {
         Zend_Registry::get('LOG')->log("Updating index: {$tips_index}", Zend_Log::NOTICE);
         $index = Zend_Search_Lucene::open($tips_index);
         // Clear index
         Zend_Registry::get('LOG')->log("Clearing index", Zend_Log::NOTICE);
         $pattern = new Zend_Search_Lucene_Index_Term('*', 'title');
         $query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
         $hits = $index->find($query);
         foreach ($hits as $hit) {
             $index->delete($hit->id);
         }
     }
     Zend_Registry::get('LOG')->log("Loading Tips", Zend_Log::NOTICE);
     $table = Zend_Registry::get('DOCTRINE_CONNECTION')->getTable('Tip');
     $tips = $table->findAll();
     foreach ($tips as $tip) {
         Zend_Registry::get('LOG')->log("  Adding tip to index: {$tip->title}", Zend_Log::NOTICE);
         $index->addDocument(Uni_Search::createDocFromTip($tip));
     }
     Zend_Registry::get('LOG')->log("", Zend_Log::NOTICE);
     Zend_Registry::get('LOG')->log("--------------------------------", Zend_Log::NOTICE);
 }
Example #15
0
 public static function getLuceneIndex()
 {
     ProjectConfiguration::registerZend();
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
     if (file_exists($index = self::getLuceneIndexFile())) {
         return Zend_Search_Lucene::open($index);
     } else {
         return Zend_Search_Lucene::create($index);
     }
 }
 /**
  * Initialise a writable database for updating the index
  * 
  * @param int flag allow setting the DB to be initialised with PluginSearchInterface::INIT_DB
  */
 public function open_writable_database($flag = 0)
 {
     Zend_Search_Lucene::setResultSetLimit(50);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
     if (PluginSearchInterface::INIT_DB == $flag) {
         $this->_index = Zend_Search_Lucene::create($this->_index_path);
     } else {
         $this->_index = Zend_Search_Lucene::open($this->_index_path);
     }
 }
Example #17
0
 public function __construct(array $config)
 {
     if (isset($config['search'])) {
         try {
             $this->_index = Zend_Search_Lucene::open($config['search']['indexPath']);
         } catch (Zend_Search_Lucene_Exception $e) {
             $this->_index = Zend_Search_Lucene::create($config['search']['indexPath']);
         }
     }
 }
Example #18
0
 /**
  * @param $dir
  * @return Zend_Search_Lucene_Interface
  */
 public static function create($dir)
 {
     //clear index path
     foreach (new DirectoryIterator($dir) as $fileInfo) {
         if ($fileInfo->isDot()) {
             continue;
         }
         unlink($fileInfo->getPath() . '/' . $fileInfo->getFilename());
     }
     return Zend_Search_Lucene::create($dir);
 }
Example #19
0
 public function getIndex()
 {
     if (!$this->_index) {
         $index = sfConfig::get('sf_data_dir') . '/sympal_' . sfConfig::get('sf_environment') . '_search.index';
         if (file_exists($index)) {
             $this->_index = Zend_Search_Lucene::open($index);
         } else {
             $this->_index = Zend_Search_Lucene::create($index);
         }
     }
     return $this->_index;
 }
Example #20
0
 protected function createLuceneIndex()
 {
     if (file_exists(dmOs::join($this->getFullPath(), 'segments.gen'))) {
         try {
             $this->luceneIndex = Zend_Search_Lucene::open($this->getFullPath());
             $this->luceneIndex->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3);
         } catch (Zend_Search_Lucene_Exception $e) {
             $this->erase();
         }
     } else {
         $this->luceneIndex = Zend_Search_Lucene::create($this->getFullPath());
     }
 }
 public function indexAction()
 {
     $indexName = 'media-index';
     $module = 'media';
     $index = Zend_Search_Lucene::create(APPLICATION_ROOT . '/data/' . $indexName);
     $moduleMapperName = ucfirst($module) . '_Model_Mapper_' . ucfirst($module);
     $moduleMapper = new $moduleMapperName();
     $moduleMapper = new Media_Model_Mapper_Media();
     $indexModule = $moduleMapper->addSearchIndex();
     var_dump($indexModule->count());
     $form = new Admin_Form_CreateSearchIndex();
     $this->view->form = $form;
 }
Example #22
0
 public function __construct($indexDir = null)
 {
     if (empty($indexDir)) {
         throw new Zend_Exception('Index Directory can not be empty!');
     }
     try {
         $indexDir = KUTU_ROOT_DIR . $indexDir;
         $this->_index = Zend_Search_Lucene::open($indexDir);
     } catch (Exception $e) {
         $this->_index = Zend_Search_Lucene::create($indexDir);
     }
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
 }
Example #23
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $dataPath = DATA_PATH . '/search';
     if (!is_writable(DATA_PATH)) {
         die('The directory ' . DATA_PATH . ' is not writable');
     }
     try {
         $this->_data = Zend_Search_Lucene::open($dataPath);
     } catch (Exception $error) {
         $this->_data = Zend_Search_Lucene::create($dataPath);
     }
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
 }
Example #24
0
 public function __construct()
 {
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
     $indexPath = APPLICATION_PATH . '/modules/' . MODULE_NAME . '/search/index';
     if (file_exists($indexPath)) {
         $this->_index = Zend_Search_Lucene::open($indexPath);
     } else {
         Bbx_Log::write('Creating index file', null, self::LOG);
         $this->_index = Zend_Search_Lucene::create($indexPath);
         if (!$this->_index instanceof Zend_Search_Lucene_Interface) {
             Bbx_Log::write('Unable to create index file', null, self::LOG);
         }
     }
 }
Example #25
0
 public function init()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     ini_set('max_execution_time', 0);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
     $indexPath = TEMP_PATH . '/Search';
     $files = glob($indexPath . '/*.*');
     // чистим старй индекс
     foreach ($files as $file) {
         unlink($file);
     }
     $this->_indexHandle = Zend_Search_Lucene::create($indexPath);
 }
Example #26
0
 public function __construct($indexDir = null)
 {
     if (empty($indexDir)) {
         $registry = Zend_Registry::getInstance();
         $conf = $registry->get('config');
         $indexDir = KUTU_ROOT_DIR . $conf->indexing->dir;
     }
     try {
         $this->_index = Zend_Search_Lucene::open($indexDir);
     } catch (Exception $e) {
         $this->_index = Zend_Search_Lucene::create($indexDir);
     }
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
 }
Example #27
0
function searchGetIndex()
{
    $index = null;
    try {
        $index = Zend_Search_Lucene::open(SEARCH_INDEX_LOCATION);
    } catch (Exception $e) {
        try {
            $index = Zend_Search_Lucene::create(SEARCH_INDEX_LOCATION);
            searchImportAll($index);
        } catch (Exception $e) {
            print "something really bad happened.";
        }
    }
    return $index;
}
Example #28
0
function createInitialIndex($indexPath)
{
    print "Creating initial index...";
    $index = Zend_Search_Lucene::create($indexPath);
    $data = getIndexablePseudoData();
    foreach ($data as $k => $v) {
        // add the document
        $doc = new Zend_Search_Lucene_Document();
        $doc->addField(Zend_Search_Lucene_Field::Text('myDocumentIdentifier', $k));
        $doc->addField(Zend_Search_Lucene_Field::Text('myDocumentContent', $v));
        $index->addDocument($doc);
    }
    print "done <br>\n";
    unset($index);
}
Example #29
0
 /**
  * This method is called before the first test of this test class is run.
  *
  * Build a temporary index with a couple of documents
  */
 public static function setUpBeforeClass()
 {
     // ensure no index exist
     system(sprintf("rm -rf %s", self::indexDir()));
     // create the index
     $index = Zend_Search_Lucene::create(self::indexDir());
     // add some documents
     for ($i = 0; $i < 3; $i++) {
         $document = new Zend_Search_Lucene_Document();
         $document->addField(Zend_Search_Lucene_Field::text('title', "foo bar baz {$i}"));
         $document->addField(Zend_Search_Lucene_Field::text('content', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc pharetra laoreet sodales. Aenean consequat ornare aliquam. Etiam vestibulum ultrices elit nec vestibulum'));
         $index->addDocument($document);
     }
     $index->commit();
 }
Example #30
0
function lucene_open()
{
    global $globals, $lucene_stopwords;
    // Change the token analyzer
    $analyzer = new Mnm_Lucene_Analysis_Analyzer_Common_Utf8Num($lucene_stopwords);
    Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
    if (file_exists($globals['lucene_dir'])) {
        $index = Zend_Search_Lucene::open($globals['lucene_dir']);
    } else {
        print "Creando dir\n";
        $index = Zend_Search_Lucene::create($globals['lucene_dir']);
        @chmod($globals['lucene_dir'], 0777);
    }
    return $index;
}