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


PHP Zend_Search_Lucene::create方法代码示例

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


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

示例1: buildPostSearch

 /**
  * 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;
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:37,代码来源:SearchProvider.php

示例2: getInstance

 /**
  * 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];
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:38,代码来源:Lucene.php

示例3: buildplaces

 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);
 }
开发者ID:abdulnizam,项目名称:zend-freniz,代码行数:26,代码来源:places.php

示例4: getLucene

 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;
 }
开发者ID:jkimdon,项目名称:cohomeals,代码行数:27,代码来源:Index.php

示例5: __construct

 /**
  * 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());
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:30,代码来源:zend_lucene.php

示例6: updateAction

 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);
         }
     }
 }
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:30,代码来源:SearchIndexController.php

示例7: buildAction

 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();
 }
开发者ID:mtaha1990,项目名称:onlineDR,代码行数:30,代码来源:SearchController.php

示例8: luceneIndexAction

 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();
     }
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:29,代码来源:ImageController.php

示例9: create

 /**
  * 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;
 }
开发者ID:sonicmaster,项目名称:RPG,代码行数:15,代码来源:LuceneEditor.class.php

示例10: getLuceneIndex

 public static function getLuceneIndex()
 {
     ProjectConfiguration::registerZend();
     if (file_exists($index = self::getLuceneIndexFile())) {
         return Zend_Search_Lucene::open($index);
     }
     return Zend_Search_Lucene::create($index);
 }
开发者ID:vcgato29,项目名称:poff,代码行数:8,代码来源:ProductTable.class.php

示例11: __construct

 /**
  * 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);
     }
 }
开发者ID:jacomyma,项目名称:GEXF-Atlas,代码行数:13,代码来源:zend_lucene.php

示例12: indexAction

 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());
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:9,代码来源:AdminController.php

示例13: init

 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());
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:9,代码来源:IndexController.php

示例14: buildIndex

 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);
 }
开发者ID:Tony133,项目名称:zf-web,代码行数:56,代码来源:Search.php

示例15: getLuceneIndex

 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);
     }
 }
开发者ID:hielh,项目名称:abjihproject,代码行数:10,代码来源:trackTable.class.php


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