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


PHP Zend_Search_Lucene::open方法代码示例

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


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

示例1: __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

示例2: __construct

 /**
  * Construct, create index
  *
  * @param string $indexPath[optional]
  * @param string $encoding[optional]
  * @throws Axis_Exception
  */
 public function __construct(array $params)
 {
     $encoding = $this->_encoding;
     $indexPath = array_shift($params);
     if (count($params)) {
         $encoding = array_shift($params);
     }
     if (null === $indexPath) {
         $site = Axis::getSite()->id;
         $locale = Axis::single('locale/language')->find(Axis_Locale::getLanguageId())->current()->locale;
         $indexPath = Axis::config()->system->path . '/var/index/' . $site . '/' . $locale;
     }
     if (!is_readable($indexPath)) {
         throw new Axis_Exception(Axis::translate('search')->__('Please, update search indexes, to enable search functionality'));
     }
     /*
     $mySimilarity = new Axis_Similarity();
     Zend_Search_Lucene_Search_Similarity::setDefault($mySimilarity);
     */
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding($encoding);
     // add filter by words
     $stopWords = array('a', 'an', 'at', 'the', 'and', 'or', 'is', 'am');
     $stopWordsFilter = new Zend_Search_Lucene_Analysis_TokenFilter_StopWords($stopWords);
     $analyzer = new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive();
     $analyzer->addFilter($stopWordsFilter);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault($analyzer);
     $this->_index = Zend_Search_Lucene::open($indexPath);
     $this->_encoding = $encoding;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:36,代码来源:Lucene.php

示例3: resultAction

 public function resultAction()
 {
     if ($this->getRequest()->isGet()) {
         $page = $this->getRequest()->getParam('page') ? $this->getRequest()->getParam('page') : 1;
         $limit = 5;
         switch (strtolower($this->getRequest()->getParam('type'))) {
             case 'blog':
                 $index = Zend_Search_Lucene::open(Zend_Registry::getInstance()->config->search->feed);
                 break;
             default:
             case 'post':
                 $index = Zend_Search_Lucene::open(Zend_Registry::getInstance()->config->search->post);
                 break;
                 /*
                       require_once 'Zend/Search/Lucene/MultiSearcher.php';
                       $index = new Zend_Search_Lucene_Interface_MultiSearcher();
                       $index->addIndex(Zend_Search_Lucene::open(Zend_Registry::getInstance()->config->search->post));
                       $index->addIndex(Zend_Search_Lucene::open(Zend_Registry::getInstance()->config->search->feed));
                   break;
                 *
                 */
         }
         $this->view->term = $this->getRequest()->getParam('term');
         //todo filter term
         $this->view->results = $index->find($this->view->term);
         $this->view->paginator = Zend_Paginator::factory($this->view->results);
         $this->view->paginator->setCurrentPageNumber($page);
         $this->view->paginator->setItemCountPerPage($limit);
     }
 }
开发者ID:aprondak,项目名称:ifphp,代码行数:30,代码来源:SearchController.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: luceneSearchAction

 public function luceneSearchAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $path = PUBLIC_PATH . '/tmp/lucene';
     $index = Zend_Search_Lucene::open($path);
     //        $term  = new Zend_Search_Lucene_Index_Term('ritesh','title');
     //        $subquery1 = new Zend_Search_Lucene_Search_Query_Term($term);
     //
     //        $from = new Zend_Search_Lucene_Index_Term('0', 'empcode');
     //        $to   = new Zend_Search_Lucene_Index_Term('53', 'empcode');
     //        $subquery2 = new Zend_Search_Lucene_Search_Query_Range($from, $to, true);
     //
     //        $query = new Zend_Search_Lucene_Search_Query_Boolean();
     //        $query->addSubquery($subquery1, true  );
     //        $query->addSubquery($subquery2, null );
     //        Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
     //        $hits  = $index->find($query);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
     Zend_Search_Lucene_Search_Query_Wildcard::setMinPrefixLength(1);
     $hits = $index->find("empcode:[000 TO 200]");
     foreach ($hits as $h) {
         echo "Title:" . $h->title;
         echo "-------EmpCode:" . $h->empcode;
         echo "<br>";
     }
 }
开发者ID:riteshsahu1981,项目名称:we,代码行数:27,代码来源:ImageController.php

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

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

示例8: getIndex

 /**
  * @param $path
  * @return \Zend_Search_Lucene_Interface|null
  */
 public function getIndex($path)
 {
     try {
         return Search::open($path);
     } catch (SearchException $e) {
         error_log($e->getMessage());
         return null;
     }
 }
开发者ID:abouthalf,项目名称:archies-recipes,代码行数:13,代码来源:SearchProvider.php

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

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

示例11: __construct

 public function __construct(array $config)
 {
     if (isset($config['search'])) {
         try {
             $this->_index = Zend_Search_Lucene::open($config['search']['indexPath']);
         } catch (Zend_Search_Lucene_Exception $e) {
             $this->_index = Zend_Search_Lucene::create($config['search']['indexPath']);
         }
     }
 }
开发者ID:padraic,项目名称:ZFPlanet,代码行数:10,代码来源:LuceneIndexer.php

示例12: open_writable_database

 /**
  * Initialise a writable database for updating the index
  * 
  * @param int flag allow setting the DB to be initialised with PluginSearchInterface::INIT_DB
  */
 public function open_writable_database($flag = 0)
 {
     Zend_Search_Lucene::setResultSetLimit(50);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8());
     if (PluginSearchInterface::INIT_DB == $flag) {
         $this->_index = Zend_Search_Lucene::create($this->_index_path);
     } else {
         $this->_index = Zend_Search_Lucene::open($this->_index_path);
     }
 }
开发者ID:habari-extras,项目名称:multisearch,代码行数:15,代码来源:zendsearchlucene.php

示例13: searchAction

 public function searchAction()
 {
     if ($this->_request->isPost() && Digitalus_Filter_Post::has('submitSearchForm')) {
         $index = Zend_Search_Lucene::open('./application/modules/search/data/index');
         $queryString = Digitalus_Filter_Post::get('keywords');
         $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
         $this->view->searchResults = $index->find($query);
         $this->view->keywords = $queryString;
     }
 }
开发者ID:ngukho,项目名称:ducbui-cms,代码行数:10,代码来源:PublicController.php

示例14: getInstances

 public static function getInstances()
 {
     $ret = array();
     foreach (new DirectoryIterator('cache/fulltext') as $i) {
         if ($i->isDir() && !$i->isDot()) {
             $ret[$i->getFilename()] = Zend_Search_Lucene::open('cache/fulltext/' . $i->getFilename());
         }
     }
     return $ret;
 }
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:10,代码来源:Lucene.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::open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。