當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Search_Lucene_Interface::optimize方法代碼示例

本文整理匯總了PHP中Zend_Search_Lucene_Interface::optimize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Search_Lucene_Interface::optimize方法的具體用法?PHP Zend_Search_Lucene_Interface::optimize怎麽用?PHP Zend_Search_Lucene_Interface::optimize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Search_Lucene_Interface的用法示例。


在下文中一共展示了Zend_Search_Lucene_Interface::optimize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: index

 /**
  * Index a file
  *
  * @param   string  $filePath   The file path
  */
 public function index($filePath)
 {
     $content = file_get_contents($filePath);
     $modificationTime = filemtime($filePath);
     $checksum = md5($content);
     // Get the document
     $hits = $this->_data->find('path:' . $filePath);
     if (count($hits) > 0) {
         $hit = $hits[0];
         $document = $hit->getDocument();
         // If the checksums are the same, no need to update
         if ($checksum === $document->checksum) {
             return;
         }
         // Delete the document
         $this->_data->delete($hit);
     }
     // Create a new document
     $document = new Zend_Search_Lucene_Document();
     $document->addField(Zend_Search_Lucene_Field::keyword('path', $filePath));
     $document->addField(Zend_Search_Lucene_Field::keyword('modificationTime', $modificationTime));
     $document->addField(Zend_Search_Lucene_Field::keyword('checksum', $checksum));
     $document->addField(Zend_Search_Lucene_Field::unStored('content', $content, 'utf-8'));
     $this->_data->addDocument($document);
     // Commit the changes
     $this->_data->commit();
     $this->_data->optimize();
 }
開發者ID:neolao,項目名稱:wiki,代碼行數:33,代碼來源:Search.php

示例2: renewIndex

 public static function renewIndex($forceCreate = false)
 {
     $pages = Application_Model_Mappers_PageMapper::getInstance()->getPagesForSearchIndex();
     if (!is_array($pages)) {
         return false;
     }
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
     self::removeIndex() && self::initIndex();
     array_walk($pages, array('Tools_Search_Tools', 'addPageToIndex'));
     self::$_index->optimize();
 }
開發者ID:PavloKovalov,項目名稱:seotoaster,代碼行數:12,代碼來源:Tools.php

示例3: indexationEnds

 /**
  * @param AJXP_Node $parentNode
  */
 public function indexationEnds($parentNode)
 {
     $this->logDebug('INDEX.END', 'Optimizing Index');
     $this->currentIndex->optimize();
     $this->logDebug('INDEX.END', 'Commiting Index');
     $this->currentIndex->commit();
     unset($this->currentIndex);
     $this->logDebug('INDEX.END', 'Merging Temporary in main');
     $this->mergeTemporaryIndexToMain($parentNode->getRepositoryId());
     $this->logDebug('INDEX.END', 'Done');
 }
開發者ID:thermalpaste,項目名稱:pydio-core,代碼行數:14,代碼來源:class.AjxpLuceneIndexer.php

示例4: _index

 /**
  * Instanciate the Lucene index
  * 
  * The index will be created if it doesn't exist yet.
  * 
  * @return \Zend_Search_Lucene_Interface							Lucene index instance
  * @throws Exception											If the index cannot be created
  */
 protected function _index()
 {
     // One-time instanciation or creation of the lucene index
     if ($this->_index === null) {
         // Try to instanciate an existing lucene index
         try {
             $this->_index = \Zend_Search_Lucene::open($this->_indexDirectory);
             // If an error occurs ...
         } catch (\Zend_Search_Lucene_Exception $e) {
             // Try to create a new lucene index ...
             try {
                 $this->_index = \Zend_Search_Lucene::create($this->_indexDirectory);
                 // If an error occurs: Failure
             } catch (\Zend_Search_Lucene_Exception $e) {
                 throw new Exception(sprintf('Error creating lucene index in "%1$s", reason: "%2$s"', $this->_indexDirectory, $e->getMessage()));
             }
         }
         // Index setup
         \Zend_Search_Lucene_Storage_Directory_Filesystem::setDefaultFilePermissions(0664);
         \Zend_Search_Lucene_Analysis_Analyzer::setDefault(new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
         \Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
         // Minimize memory consumption
         $this->_index->setMaxBufferedDocs(1);
         // Set optimization frequency
         $this->_index->setMergeFactor(max(1, intval($GLOBALS['TYPO3_CONF_VARS']['EXT']['extParams']['tw_lucenesearch']['mergeFactor'])));
         // If applicable: Optimize index
         if ($this->_indexOptimize) {
             $this->_index->optimize();
         }
         $this->_index->commit();
         if (TYPO3_MODE == 'FE') {
             \Zend_Search_Lucene::setTermsPerQueryLimit(\Tollwerk\TwLucenesearch\Utility\Indexer::indexConfig($GLOBALS['TSFE'], 'search.limits.query'));
         }
     }
     return $this->_index;
 }
開發者ID:GerDner,項目名稱:TYPO3-ext-tw_lucenesearch,代碼行數:44,代碼來源:Lucene.php

示例5: optimize

 /**
  * Optimize index.
  *
  * Merges all segments into one
  */
 public function optimize()
 {
     $this->_index->optimize();
 }
開發者ID:abdulhadikaryana,項目名稱:kebudayaan,代碼行數:9,代碼來源:Proxy.php


注:本文中的Zend_Search_Lucene_Interface::optimize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。