当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Search_Lucene::optimize方法代码示例

本文整理汇总了PHP中Zend_Search_Lucene::optimize方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Search_Lucene::optimize方法的具体用法?PHP Zend_Search_Lucene::optimize怎么用?PHP Zend_Search_Lucene::optimize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Search_Lucene的用法示例。


在下文中一共展示了Zend_Search_Lucene::optimize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: edit

 public function edit($needFields = array(), $data = array(), $charset = 'UTF-8')
 {
     $index = new Zend_Search_Lucene(ZY_ROOT . '/index');
     $doc = new Zend_Search_Lucene_Document();
     foreach ($needFields as $key => $field) {
         switch ($field) {
             case 'keywords':
                 $doc->addField(Zend_Search_Lucene_Field::Keyword($key, $data[$key], $charset));
                 break;
             case 'text':
                 $doc->addField(Zend_Search_Lucene_Field::Text($key, $data[$key], $charset));
                 break;
             case 'unindexed':
                 $doc->addField(Zend_Search_Lucene_Field::unindexed($key, $data[$key], $charset));
                 break;
             default:
                 $doc->addField(Zend_Search_Lucene_Field::$field($key, $data[$key], $charset));
                 break;
         }
     }
     $index->addDocument($doc);
     $index->commit();
     $index->optimize();
     return TRUE;
 }
开发者ID:BGCX262,项目名称:zyshop-svn-to-git,代码行数:25,代码来源:search_lucnene.php

示例2: optimizeIndex

 public function optimizeIndex()
 {
     // optimize lucene index for better performance
     $this->index->optimize();
     //clean up
     if (is_object($this->index) and $this->index instanceof \Zend_Search_Lucene_Proxy) {
         $this->index->removeReference();
         unset($this->index);
         \Pimcore\Logger::debug('LuceneSearch: Closed frontend index references');
     }
     \Pimcore\Logger::debug('LuceneSearch: optimizeIndex.');
 }
开发者ID:dachcom-digital,项目名称:pimcore-lucene-search,代码行数:12,代码来源:Parser.php

示例3: removeFromIndex

 /**
  * removeFromIndex
  * @param string $strIndexPath
  * @param string $strKey
  * @author Thomas Schedler <tsh@massiveart.com>
  * @version 1.0
  */
 protected final function removeFromIndex($strIndexPath, $strKey)
 {
     try {
         if (count(scandir($strIndexPath)) > 2) {
             $this->objIndex = Zend_Search_Lucene::open($strIndexPath);
             $objTerm = new Zend_Search_Lucene_Index_Term($strKey, 'key');
             $objQuery = new Zend_Search_Lucene_Search_Query_Term($objTerm);
             $objHits = $this->objIndex->find($objQuery);
             foreach ($objHits as $objHit) {
                 $this->objIndex->delete($objHit->id);
             }
             $this->objIndex->commit();
             $this->objIndex->optimize();
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:25,代码来源:generic.data.type.abstract.class.php

示例4: removeFromIndex

 /**
  * removeFromIndex
  * @param string $strIndexPath
  * @param string $strKey
  * @author Thomas Schedler <tsh@massiveart.com>
  * @version 1.0
  */
 protected final function removeFromIndex($strIndexPath, $strKey)
 {
     try {
         $this->core->logger->debug('massiveart->generic->data->types->GenericDataTypeAbstract->removeFromIndex(' . $strIndexPath . ', ' . $strKey . ')');
         if (count(scandir($strIndexPath)) > 2) {
             $this->objIndex = Zend_Search_Lucene::open($strIndexPath);
             $objTerm = new Zend_Search_Lucene_Index_Term($strKey, 'key');
             $objQuery = strpos($strKey, '*') !== false ? new Zend_Search_Lucene_Search_Query_Wildcard($objTerm) : new Zend_Search_Lucene_Search_Query_Term($objTerm);
             $objHits = $this->objIndex->find($objQuery);
             foreach ($objHits as $objHit) {
                 $this->objIndex->delete($objHit->id);
             }
             $this->objIndex->commit();
             $this->objIndex->optimize();
         }
     } catch (Exception $exc) {
         $this->core->logger->err($exc);
     }
 }
开发者ID:BGCX261,项目名称:zoolu-svn-to-git,代码行数:26,代码来源:generic.data.type.abstract.class.php

示例5: optimise

 /**
  * Optimise the lucene index.
  * This can be called periodically to optimise performance and size of the lucene index.
  *
  */
 public function optimise()
 {
     parent::optimise();
     $this->lucene->optimize();
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:10,代码来源:PHPLuceneIndexer.inc.php

示例6: updateIndex

 private function updateIndex()
 {
     $models = array('ConceptualDomain', 'DataElement', 'DataElementConcept', 'Dimensionality', 'NonEnumeratedConceptualDomain', 'NonEnumeratedValueDomain', 'ObjectClass', 'Property', 'UnitOfMeasure', 'Value', 'ValueDomain', 'ValueMeaning');
     foreach ($models as $model) {
         $modelName = $this->modelPrefix . $model;
         $m = new $modelName();
         $values = $m->fetchAll();
         foreach ($values as $value) {
             $valuesArray = $value->toArray();
             $url = $this->view->url(array('module' => 'default', 'controller' => 'Index', 'action' => 'edit', 'model' => $model, 'id' => $valuesArray[$m->getPrimaryKey()]), '', true);
             $this->addEntryToSearchIndex($url, $valuesArray);
         }
     }
     $options = $this->getInvokeArg('bootstrap')->getOption('lucene');
     $luceneDir = $options['dir'];
     $doc = new Zend_Search_Lucene_Document();
     $index = new Zend_Search_Lucene($luceneDir);
     $index->optimize();
 }
开发者ID:rollxx,项目名称:iso,代码行数:19,代码来源:IndexController.php

示例7: actionCreate

 /**
  * Search index creation
  */
 public function actionCreate()
 {
     /**
      * Если это не AJAX-запрос - посылаем:
      **/
     if (!Yii::app()->getRequest()->getIsPostRequest() && !Yii::app()->getRequest()->getIsAjaxRequest()) {
         throw new CHttpException(404, Yii::t('ZendSearchModule.zendsearch', 'Page was not found!'));
     }
     try {
         // Папка для хранения индекса поиска
         $indexFiles = Yii::app()->getModule('zendsearch')->indexFiles;
         // Модели, включенные в индекс
         $searchModels = Yii::app()->getModule('zendsearch')->searchModels;
         // Лимит количества символов к описанию превью найденной страницы
         $limit = 600;
         SetLocale(LC_ALL, 'ru_RU.UTF-8');
         $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
         Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
         $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $indexFiles), true);
         $messages = [];
         if (extension_loaded('iconv') === true) {
             // Пробежаться по всем моделям и добавить их в индекс
             foreach ($searchModels as $modelName => $model) {
                 if (!empty($model['path'])) {
                     Yii::import($model['path']);
                 }
                 if (!isset($model['module'])) {
                     $messages[] = Yii::t('ZendSearchModule.zendsearch', 'Update config file or module, Module index not found for model "{model}"!', ['{model}' => $modelName]);
                 } elseif (is_file(Yii::getPathOfAlias($model['path']) . '.php') && Yii::app()->hasModule($model['module'])) {
                     $criteria = isset($model['criteria']) ? $model['criteria'] : [];
                     $searchNodes = $modelName::model()->findAll(new CDbCriteria($criteria));
                     foreach ($searchNodes as $node) {
                         $doc = new Zend_Search_Lucene_Document();
                         $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($node->{$model}['titleColumn']), 'UTF-8'));
                         $link = str_replace('{' . $model['linkColumn'] . '}', $node->{$model}['linkColumn'], $model['linkPattern']);
                         $doc->addField(Zend_Search_Lucene_Field::Text('link', $link, 'UTF-8'));
                         $contentColumns = explode(',', $model['textColumns']);
                         $i = 0;
                         foreach ($contentColumns as $column) {
                             $content = $this->cleanContent($node->{$column});
                             if ($i == 0) {
                                 $doc->addField(Zend_Search_Lucene_Field::Text('content', $content, 'UTF-8'));
                                 $description = $this->cleanContent($this->previewContent($node->{$column}, $limit));
                                 $doc->addField(Zend_Search_Lucene_Field::Text('description', $description, 'UTF-8'));
                             } else {
                                 $doc->addField(Zend_Search_Lucene_Field::Text('content' . $i, $content, 'UTF-8'));
                             }
                             $i++;
                         }
                         $index->addDocument($doc);
                     }
                     $index->optimize();
                     $index->commit();
                 } else {
                     $messages[] = Yii::t('ZendSearchModule.zendsearch', 'Module "{module}" not installed!', ['{module}' => $model['module']]);
                 }
             }
         } else {
             $messages[] = Yii::t('ZendSearchModule.zendsearch', 'This module require "Iconv" extension!');
         }
         Yii::app()->ajax->raw(empty($messages) ? Yii::t('ZendSearchModule.zendsearch', 'Index updated successfully!') : Yii::t('ZendSearchModule.zendsearch', 'There is an error!') . ': ' . implode("\n", $messages));
     } catch (Exception $e) {
         Yii::app()->ajax->raw(Yii::t('ZendSearchModule.zendsearch', 'There is an error!') . ":\n" . $e->getMessage());
     }
 }
开发者ID:yupe,项目名称:yupe,代码行数:68,代码来源:ManageBackendController.php


注:本文中的Zend_Search_Lucene::optimize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。