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


PHP Zend_Search_Lucene::commit方法代碼示例

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


在下文中一共展示了Zend_Search_Lucene::commit方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: actionIndexing

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndexing()
 {
     ini_set('max_execution_time', 0);
     ob_start();
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
     $criteria = new CDbCriteria();
     $criteria->compare('t.publish', 1);
     $criteria->order = 'album_id DESC';
     //$criteria->limit = 10;
     $model = Albums::model()->findAll($criteria);
     foreach ($model as $key => $item) {
         if ($item->media_id != 0) {
             $images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
         } else {
             $images = '';
         }
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
         $index->addDocument($doc);
     }
     echo 'Album Lucene index created';
     $index->commit();
     $this->redirect(Yii::app()->createUrl('article/search/indexing'));
     ob_end_flush();
 }
開發者ID:OmmuOpenSource,項目名稱:OOS-Company-Profile,代碼行數:35,代碼來源:SearchController.php

示例3: index

 function index()
 {
     $this->load->library('zend', 'Zend/Feed');
     $this->load->library('zend', 'Zend/Search/Lucene');
     $this->load->library('zend');
     $this->zend->load('Zend/Feed');
     $this->zend->load('Zend/Search/Lucene');
     //Create index.
     $index = new Zend_Search_Lucene('C:\\xampp\\xampp\\htdocs\\controle_frota\\lucene\\feeds_index', true);
     $feeds = array('http://oglobo.globo.com/rss.xml?limite=50');
     //grab each feed.
     foreach ($feeds as $feed) {
         $channel = Zend_Feed::import($feed);
         echo $channel->title() . '<br />';
         //index each item.
         foreach ($channel->items as $item) {
             if ($item->link() && $item->title() && $item->description()) {
                 //create an index doc.
                 $doc = new Zend_Search_Lucene_Document();
                 $doc->addField(Zend_Search_Lucene_Field::Keyword('link', $this->sanitize($item->link())));
                 $doc->addField(Zend_Search_Lucene_Field::Text('title', $this->sanitize($item->title())));
                 $doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $this->sanitize($item->description())));
                 echo "\tAdding: " . $item->title() . '<br />';
                 $index->addDocument($doc);
             }
         }
     }
     $index->commit();
     echo $index->count() . ' Documents indexed.<br />';
 }
開發者ID:ramonsilvanet,項目名稱:controle-frota-php,代碼行數:30,代碼來源:pesquisas.php

示例4: fill_index

function fill_index()
{
    for ($i = 0; $i < 10; $i++) {
        $index = new Zend_Search_Lucene('./data/index', true);
        $index->find("test");
        $doc = new Zend_Search_Lucene_Document();
        $doc->addField(Zend_Search_Lucene_Field::Text("test", getword()));
        $doc->addField(Zend_Search_Lucene_Field::UnStored("contents", getword()));
        $index->addDocument($doc);
        $index->commit();
        $index->getDirectory()->close();
        //comment this to see another bug :-|
    }
}
開發者ID:Tony133,項目名稱:zf-web,代碼行數:14,代碼來源:search_test.php

示例5: indexationAdd

 public static function indexationAdd($indexationData)
 {
     $directory = Zend_Registry::get('lucene_index');
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('pageID', $indexationData['pageID']));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('moduleID', $indexationData['moduleID']));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('contentID', $indexationData['contentID']));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('languageID', $indexationData['languageID']));
     $doc->addField(Zend_Search_Lucene_Field::Text('title', Cible_FunctionsGeneral::html2text($indexationData['title'])));
     $doc->addField(Zend_Search_Lucene_Field::Text('text', Cible_FunctionsGeneral::html2text($indexationData['text'])));
     $doc->addField(Zend_Search_Lucene_Field::UnIndexed('link', $indexationData['link']));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', strtolower(Cible_FunctionsGeneral::removeAccents(Cible_FunctionsGeneral::html2text($indexationData['contents'])))));
     $newIndex = !is_dir($directory);
     $index = new Zend_Search_Lucene($directory, $newIndex);
     $index->addDocument($doc);
     $index->commit();
 }
開發者ID:anunay,項目名稱:stentors,代碼行數:18,代碼來源:FunctionsIndexation.php

示例6: 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

示例7: actionCreate

 public function actionCreate()
 {
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles), true);
     $items = Items::model()->findAll();
     foreach ($items as $item) {
         $doc = new Zend_Search_Lucene_Document();
         Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
         $doc->addField(Zend_Search_Lucene_Field::keyword('part_number', CHtml::encode($item->part_number), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('name', CHtml::encode($item->name), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('description', CHtml::encode($item->description), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('barcode', CHtml::encode($item->barcode), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::float('available_quantity', CHtml::encode($item->available_quantity), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::float('current_quantity', CHtml::encode($item->current_quantity), 'utf-8'));
         $index->addDocument($doc);
     }
     $index->commit();
     echo 'Lucene index created';
 }
開發者ID:EmmanuelFernando,項目名稱:rapport-stock-control,代碼行數:18,代碼來源:SearchController.php

示例8: 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

示例9: addEntryToSearchIndex

 private function addEntryToSearchIndex($url, array $content)
 {
     $options = $this->getInvokeArg('bootstrap')->getOption('lucene');
     $luceneDir = $options['dir'];
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('url', $url));
     foreach ($content as $key => $value) {
         if (!is_array($value) && $value && strlen($value) && !is_numeric($value)) {
             $doc->addField(Zend_Search_Lucene_Field::Text($key, $value));
         }
     }
     $newIndex = !is_dir($luceneDir);
     $index = new Zend_Search_Lucene($luceneDir, $newIndex);
     $index->addDocument($doc);
     $index->commit();
     //        $index->optimize();
 }
開發者ID:rollxx,項目名稱:iso,代碼行數:17,代碼來源:IndexController.php

示例10: actionIndexing

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndexing()
 {
     ini_set('max_execution_time', 0);
     ob_start();
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
     $criteria = new CDbCriteria();
     $now = new CDbExpression("NOW()");
     $criteria->compare('t.publish', 1);
     $criteria->compare('date(published_date) <', $now);
     $criteria->order = 'article_id DESC';
     //$criteria->limit = 10;
     $model = Articles::model()->findAll($criteria);
     foreach ($model as $key => $item) {
         if ($item->media_id != 0) {
             $images = Yii::app()->request->baseUrl . '/public/article/' . $item->article_id . '/' . $item->cover->media;
         } else {
             $images = '';
         }
         if (in_array($item->cat_id, array(2, 3, 5, 6, 7, 18))) {
             $url = Yii::app()->createUrl('article/news/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
         } else {
             if (in_array($item->cat_id, array(9))) {
                 $url = Yii::app()->createUrl('article/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
             } else {
                 if (in_array($item->cat_id, array(10, 15, 16))) {
                     $url = Yii::app()->createUrl('article/archive/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                 } else {
                     if (in_array($item->cat_id, array(23, 24, 25))) {
                         $url = Yii::app()->createUrl('article/newspaper/site/view', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                     } else {
                         if (in_array($item->cat_id, array(13, 14, 20, 21))) {
                             $url = Yii::app()->createUrl('article/regulation/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                         } else {
                             if (in_array($item->cat_id, array(19))) {
                                 $url = Yii::app()->createUrl('article/announcement/site/download', array('id' => $item->article_id, 't' => Utility::getUrlTitle($item->title)));
                             }
                         }
                     }
                 }
             }
         }
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->article_id), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Keyword('category', CHtml::encode(Phrase::trans($item->cat->name, 2)), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . $url), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->published_date, true) . ' WIB'), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
         $index->addDocument($doc);
     }
     echo 'Artkel Lucene index created';
     $index->commit();
     $this->redirect(Yii::app()->createUrl('video/search/indexing'));
     ob_end_flush();
 }
開發者ID:OmmuOpenSource,項目名稱:OOS-Company-Profile,代碼行數:61,代碼來源:SearchController.php

示例11: actionDoIndex

 public function actionDoIndex()
 {
     $document = Document::model()->findAll();
     Yii::import('application.vendor.*');
     require_once 'Zend/Search/Lucene.php';
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.index'), true);
     try {
         foreach ($document as $doc) {
             $indexDoc = new Zend_Search_Lucene_Document();
             $indexDoc->addField(Zend_Search_Lucene_Field::text("title", CHtml::encode($doc->title), 'utf-8'));
             $indexDoc->addField(Zend_Search_Lucene_Field::text("content", CHtml::encode($doc->content), 'utf-8'));
             $indexDoc->addField(Zend_Search_Lucene_Field::text("author", CHtml::encode($doc->author), 'utf-8'));
             $indexDoc->addField(Zend_Search_Lucene_Field::unIndexed("id", CHtml::encode($doc->id), 'utf-8'));
             $indexDoc->addField(Zend_Search_Lucene_Field::keyword("url", CHtml::encode($doc->url), 'utf-8'));
             $index->addDocument($indexDoc);
         }
         $index->commit();
         Yii::app()->user->setFlash('success', 'Indexing success!');
     } catch (Exception $e) {
         Yii::app()->user->setFlash('error', 'Indexing fail, try again!');
     }
     $this->redirect(array('document/admin'));
 }
開發者ID:httvncoder,項目名稱:tugastkilucene,代碼行數:23,代碼來源:DocumentController.php

示例12: 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

示例13: insert

 function insert($val = array())
 {
     $this->link();
     $index = new Zend_Search_Lucene($this->dir);
     $analyzerObj = new search_instance_analyzer_cjk();
     $analyzerObj->addPreFilter(new search_instance_analyzer_filter_goods());
     $analyzerObj->addPreFilter(new search_instance_analyzer_filter_cjk());
     $analyzerObj->addFilter(new search_instance_token_filter_lowercase());
     Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzerObj);
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Text('goods_id', $val['goods_id']));
     if (isset($val['product'][0]['price']['price']['price'])) {
         $pric = $val['product'][0]['price']['price']['price'];
     } else {
         if (is_array($val['product'])) {
             foreach ($val['product'] as $kp => $vp) {
                 $pric = $vp['price']['price']['price'];
             }
         }
     }
     $doc->addField(Zend_Search_Lucene_Field::UnStored('cat_id', $val['category']['cat_id']));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('brand_id', $val['brand']['brand_id']));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('price', $this->priceChange($pric)));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('marketable', 'true'));
     if (isset($val['props'])) {
         for ($i = 1; $i <= 28; $i++) {
             $p = 'p_' . $i;
             $doc->addField(Zend_Search_Lucene_Field::UnStored($p, $val['props'][$p]['value']));
         }
     }
     if (is_array($val['keywords'])) {
         foreach ($val['keywords'] as $k => $v) {
             $keyword .= '#' . $v['keyword'] . '@';
         }
     }
     if (is_array($val['product'])) {
         foreach ($val['product'] as $k => $v) {
             if (is_array($v['spec_desc']['spec_value_id'])) {
                 foreach ($v['spec_desc']['spec_value_id'] as $key => $vals) {
                     $spec .= '#' . $key . $vals . '@';
                 }
             }
             $bn .= '#' . $v['bn'] . '@';
         }
     }
     //$name = '#'.$val['name'].'@'.$keyword.'#'.$val['bn'].'@'.$bn;
     $name = '#' . $val['name'] . '@';
     $doc->addField(Zend_Search_Lucene_Field::UnStored('title', $name));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('keyword', $keyword));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('spec', $spec));
     $doc->addField(Zend_Search_Lucene_Field::UnStored('bn', '#' . $val['bn'] . '@' . $bn));
     $index->addDocument($doc);
     return $index->commit();
 }
開發者ID:syjzwjj,項目名稱:quyeba,代碼行數:54,代碼來源:goods.php

示例14: saveSearchIndex

 public static function saveSearchIndex()
 {
     $index = new Zend_Search_Lucene(sfConfig::get('sf_lib_dir') . '/modules/search/tmp/lucene.user.index', true);
     $doc = new Zend_Search_Lucene_Document();
     $doc->addField(Zend_Search_Lucene_Field::Keyword('id', $this->pageDocument->getId()));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('pageid', $this->pageDocument->getId()));
     $doc->addField(Zend_Search_Lucene_Field::Keyword('title', $this->pageDocument->getNavigationTitle()));
     $blobData = $this->pageDocument->getContent();
     // $blockContents = $blobData->__toString();
     $blockContents = $blobData;
     $doc->addField(Zend_Search_Lucene_Field::Unstored('contents', $blockContents . ' ' . $this->pageDocument->getNavigationTitle()));
     $index->addDocument($doc);
     $index->commit();
     $hits = $index->find(strtolower('maquette'));
     foreach ($hits as $hit) {
         //			echo $hit->score.'<br/>';
         //			echo $hit->id;
         //			echo $hit->contents.'<br/>';
         echo $hit->pageid;
     }
 }
開發者ID:kotow,項目名稱:work,代碼行數:21,代碼來源:Document.php

示例15: RefreshSearchIndex

 /**
  * This will refresh the search index for this topic (for all message content under this topic)
  * @param Zend_Search_Lucene $objIndex should be null if we are updating just one -- but for bulk index updates, you can pass in an already loaded index file
  * @return void
  */
 public function RefreshSearchIndex($objIndex = null)
 {
     // Currently only implemented for Forum-based topic/message searches
     if ($this->TopicLink->TopicLinkTypeId != TopicLinkType::Forum) {
         return;
     }
     if (!$objIndex) {
         $objIndex = new Zend_Search_Lucene(__SEARCH_INDEXES__ . '/topics');
         $blnIndexProvided = false;
     } else {
         $blnIndexProvided = true;
     }
     // Retrievew the Index Documents (if applicable) to delete them from the index
     $objSearchTerm = new Zend_Search_Lucene_Index_Term($this->Id, 'db_id');
     foreach ($objIndex->termDocs($objSearchTerm) as $intDocId) {
         $objIndex->delete($intDocId);
     }
     // Create the Message Contents for this Topic
     $strContents = null;
     foreach ($this->GetMessageArray(QQ::OrderBy(QQN::Message()->ReplyNumber)) as $objMessage) {
         $strMessage = strip_tags(trim($objMessage->CompiledHtml));
         $strMessage = html_entity_decode($strMessage, ENT_QUOTES, 'UTF-8');
         $strContents .= $strMessage . "\r\n\r\n";
     }
     // Create the Document
     $objDocument = new Zend_Search_Lucene_Document();
     $objDocument->addField(Zend_Search_Lucene_Field::Keyword('db_id', $this->Id));
     $objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('topic_link_id', $this->TopicLinkId));
     $objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('topic_link_type_id', $this->TopicLink->TopicLinkTypeId));
     $objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('message_count', $this->MessageCount));
     $objDocument->addField(Zend_Search_Lucene_Field::UnIndexed('last_post_date', $this->LastPostDate->Timestamp));
     $objDocument->addField(Zend_Search_Lucene_Field::Text('title', $this->Name));
     $objDocument->addField(Zend_Search_Lucene_Field::UnStored('contents', trim($strContents)));
     // Add Document to Index
     $objIndex->addDocument($objDocument);
     // Only call commit on the index if it was provided for us
     if (!$blnIndexProvided) {
         $objIndex->commit();
     }
 }
開發者ID:qcodo,項目名稱:qcodo-website,代碼行數:45,代碼來源:Topic.class.php


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