本文整理汇总了PHP中Zend_Search_Lucene_Interface::setMergeFactor方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene_Interface::setMergeFactor方法的具体用法?PHP Zend_Search_Lucene_Interface::setMergeFactor怎么用?PHP Zend_Search_Lucene_Interface::setMergeFactor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Search_Lucene_Interface
的用法示例。
在下文中一共展示了Zend_Search_Lucene_Interface::setMergeFactor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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;
}
示例2: setMergeFactor
/**
* Set index mergeFactor option
*
* mergeFactor determines how often segment indices are merged by addDocument().
* With smaller values, less RAM is used while indexing,
* and searches on unoptimized indices are faster,
* but indexing speed is slower.
* With larger values, more RAM is used during indexing,
* and while searches on unoptimized indices are slower,
* indexing is faster.
* Thus larger values (> 10) are best for batch index creation,
* and smaller values (< 10) for indices that are interactively maintained.
*
* Default value is 10
*
* @param integer $maxMergeDocs
*/
public function setMergeFactor($mergeFactor)
{
$this->_index->setMergeFactor($mergeFactor);
}