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


PHP Zend_Search_Lucene类代码示例

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


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

示例1: search

 public function search($keywords, $charset = 'utf-8')
 {
     $index = new Zend_Search_Lucene(ZY_ROOT . '/index');
     $query = Zend_Search_Lucene_Search_QueryParser::parse($keywords, $charset);
     $hits = $index->find($query);
     return $hits;
 }
开发者ID:BGCX262,项目名称:zyshop-svn-to-git,代码行数:7,代码来源:search_lucnene.php

示例2: getDocument

 /**
  * Return the document object for this hit
  *
  * @return Zend_Search_Lucene_Document
  */
 public function getDocument()
 {
     if (!$this->_document instanceof Zend_Search_Lucene_Document) {
         $this->_document = $this->_index->getDocument($this->id);
     }
     return $this->_document;
 }
开发者ID:Nurudeen,项目名称:prado,代码行数:12,代码来源:QueryHit.php

示例3: onSearchLucene

 function onSearchLucene($text, $phrase = '', $ordering = '', $areas = null)
 {
     if (is_array($areas) && count($areas) > 0) {
         if (!array_intersect($areas, array_keys($this->areas))) {
             return array();
         }
     } else {
         if (count($areas) == 0) {
             $areas = array();
             foreach ($this->areas as $k => $v) {
                 $areas[] = $k;
             }
         }
     }
     $results = array();
     $params = JComponentHelper::getParams('com_search_lucene');
     $indexpath = $params->get('indexpath');
     $pluginindex = $indexpath . DS . $this->pluginName;
     $index = new Zend_Search_Lucene($pluginindex);
     $search = '(';
     foreach ($areas as $area) {
         if (array_key_exists($area, $this->areas)) {
             $search .= ' type:' . $area;
         }
     }
     $search .= ')';
     if ($index && strlen($text) > 3) {
         $rows = $index->find($text . ' AND ' . $search);
     } else {
         $rows = array();
     }
     return $rows;
 }
开发者ID:beingsane,项目名称:com-search-lucene,代码行数:33,代码来源:search_lucene_extend.php

示例4: __construct

 public function __construct($path = SEARCH_INDEX_PATH)
 {
     global $CFG, $db;
     $this->path = $path;
     //test to see if there is a valid index on disk, at the specified path
     try {
         $test_index = new Zend_Search_Lucene($this->path, false);
         $validindex = true;
     } catch (Exception $e) {
         $validindex = false;
     }
     //retrieve file system info about the index if it is valid
     if ($validindex) {
         $this->size = display_size(get_directory_size($this->path));
         $index_dir = get_directory_list($this->path, '', false, false);
         $this->filecount = count($index_dir);
         $this->indexcount = $test_index->count();
     } else {
         $this->size = 0;
         $this->filecount = 0;
         $this->indexcount = 0;
     }
     $db_exists = false;
     //for now
     //get all the current tables in moodle
     $admin_tables = $db->MetaTables();
     //TODO: use new IndexDBControl class for database checks?
     //check if our search table exists
     if (in_array($CFG->prefix . SEARCH_DATABASE_TABLE, $admin_tables)) {
         //retrieve database information if it does
         $db_exists = true;
         //total documents
         $this->dbcount = count_records(SEARCH_DATABASE_TABLE);
         //individual document types
         // $types = search_get_document_types();
         $types = search_collect_searchables(true, false);
         sort($types);
         foreach ($types as $type) {
             $c = count_records(SEARCH_DATABASE_TABLE, 'doctype', $type);
             $this->types[$type] = (int) $c;
         }
     } else {
         $this->dbcount = 0;
         $this->types = array();
     }
     //check if the busy flag is set
     if (isset($CFG->search_indexer_busy) && $CFG->search_indexer_busy == '1') {
         $this->complete = false;
     } else {
         $this->complete = true;
     }
     //get the last run date for the indexer
     if ($this->valid() && $CFG->search_indexer_run_date) {
         $this->time = $CFG->search_indexer_run_date;
     } else {
         $this->time = 0;
     }
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:58,代码来源:indexlib.php

示例5: search

 private function search($terms)
 {
     Yii::import('application.vendor.*');
     require_once 'Zend/Search/Lucene.php';
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.index'));
     $result = $index->find($terms);
     $query = Zend_Search_Lucene_Search_QueryParser::parse($terms);
     return $result;
 }
开发者ID:httvncoder,项目名称:tugastkilucene,代码行数:9,代码来源:SearchController.php

示例6: generateSitemap

 public function generateSitemap()
 {
     $this->prepareSiteMapFolder();
     if (!is_null($this->sitemapDir)) {
         $hosts = $this->getValidHosts();
         if (is_array($hosts)) {
             foreach ($hosts as $hostName) {
                 $query = new \Zend_Search_Lucene_Search_Query_Boolean();
                 $hostTerm = new \Zend_Search_Lucene_Index_Term($hostName, 'host');
                 $hostQuery = new \Zend_Search_Lucene_Search_Query_Term($hostTerm);
                 $query->addSubquery($hostQuery, TRUE);
                 $hostTerm = new \Zend_Search_Lucene_Index_Term(TRUE, 'restrictionGroup_default');
                 $hostQuery = new \Zend_Search_Lucene_Search_Query_Term($hostTerm);
                 $query->addSubquery($hostQuery, TRUE);
                 $hits = $this->index->find($query);
                 $name = str_replace('.', '-', $hostName);
                 $filePath = $this->sitemapDir . '/sitemap-' . $name . '.xml';
                 $fh = fopen($filePath, 'w');
                 fwrite($fh, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
                 fwrite($fh, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
                 fwrite($fh, "\r\n");
                 for ($i = 0; $i < count($hits); $i++) {
                     $url = $hits[$i]->getDocument()->getField('url');
                     $uri = str_replace(array('?pimcore_outputfilters_disabled=1', '&pimcore_outputfilters_disabled=1'), '', $url->value);
                     fwrite($fh, '<url>' . "\r\n");
                     fwrite($fh, '    <loc>' . htmlspecialchars($uri, ENT_QUOTES) . '</loc>' . "\r\n");
                     fwrite($fh, '</url>' . "\r\n");
                 }
                 fwrite($fh, '</urlset>' . "\r\n");
                 fclose($fh);
             }
             $filePath = $this->sitemapDir . '/sitemap.xml';
             $fh = fopen($filePath, 'w');
             fwrite($fh, '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n");
             fwrite($fh, '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
             fwrite($fh, "\r\n");
             foreach ($hosts as $hostName) {
                 $name = str_replace('.', '-', $hostName);
                 //first host must be main domain - see hint in plugin settings
                 $currenthost = $hosts[0];
                 fwrite($fh, '<sitemap>' . "\r\n");
                 fwrite($fh, '    <loc>http://' . $currenthost . '/plugin/LuceneSearch/frontend/sitemap/?sitemap=sitemap-' . $name . '.xml' . '</loc>' . "\r\n");
                 fwrite($fh, '</sitemap>' . "\r\n");
                 \Pimcore\Logger::debug('LuceneSearch: ' . $hostName . ' for sitemap.xml added.');
             }
             fwrite($fh, '</sitemapindex>' . "\r\n");
             fclose($fh);
         } else {
             \Pimcore\Logger::debug('LuceneSearch: could not generate sitemaps, did not find any hosts in index.');
         }
     } else {
         \Pimcore\Logger::emerg('LuceneSearch: Cannot generate sitemap. Sitemap directory [ ' . $this->sitemapDir . ' ]  not available/not writeable and cannot be created');
     }
 }
开发者ID:dachcom-digital,项目名称:pimcore-lucene-search,代码行数:54,代码来源:SitemapBuilder.php

示例7: actionSearch

 public function actionSearch()
 {
     //working.
     $this->layout = 'column2';
     if (($term = Yii::app()->getRequest()->getParam('q', null)) !== null) {
         Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
         $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles));
         $results = $index->find($term);
         $query = Zend_Search_Lucene_Search_QueryParser::parse($term);
         $this->render('search', compact('results', 'term', 'query'));
     }
 }
开发者ID:EmmanuelFernando,项目名称:rapport-stock-control,代码行数:12,代码来源:SearchController.php

示例8: actionSearch

 public function actionSearch()
 {
     $indexFiles = Yii::app()->getModule('zendsearch')->indexFiles;
     SetLocale(LC_ALL, 'ru_RU.UTF-8');
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive());
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('UTF-8');
     if (($term = Yii::app()->getRequest()->getQuery('q', null)) !== null) {
         $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $indexFiles));
         $results = $index->find($term);
         $query = Zend_Search_Lucene_Search_QueryParser::parse($term);
         $this->render('search', compact('results', 'term', 'query'));
     }
 }
开发者ID:sepaker,项目名称:yupe,代码行数:13,代码来源:SearchController.php

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

示例10: compact

         $results = $index->find($term);
         $query = Zend_Search_Lucene_Search_QueryParser::parse($term);
         $this->render('/sParameter/search', compact('results', 'term', 'query'));
     }
 }
 /**
  * Search index creation
  */
 public function actionCreate()
 {
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias('application.' . $this->_indexFiles), true);
     $posts = tAccount::model()->findAll();
     foreach ($posts as $post) {
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::Text('account_no', CHtml::encode($post->account_no), 'utf-8'));
开发者ID:kit9,项目名称:ERP_Accounting_Indonesia,代码行数:15,代码来源:_OLD_SearchController.php

示例11: search

 function search($query)
 {
     $this->load->library('zend', 'Zend/Search/Lucene');
     $this->load->library('zend');
     $this->zend->load('Zend/Search/Lucene');
     $index = new Zend_Search_Lucene('C:\\xampp\\xampp\\htdocs\\controle_frota\\lucene\\feeds_index');
     $hits = $index->find($query);
     echo 'Index contains ' . $index->count() . ' documents.<br /><br />';
     echo 'Search for "' . $query . '" returned ' . count($hits) . ' hits<br /><br />';
     foreach ($hits as $hit) {
         echo $hit->title . '<br />';
         echo 'Score: ' . sprintf('%.2f', $hit->score) . '<br />';
         echo $hit->link . '<br /><br />';
     }
 }
开发者ID:ramonsilvanet,项目名称:controle-frota-php,代码行数:15,代码来源:pesquisas.php

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

示例13: query

 /**
  * Enter description here...
  *
  * @param string $query
  * @return array
  */
 public function query($query)
 {
     $results = array();
     $queryDiscussion = stripos($query, 'discussion') !== false;
     $queryContent = stripos($query, 'content') !== false;
     $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
     $hits = $this->lucene->find($query);
     foreach ($hits as $hit) {
         $document = $hit->getDocument();
         $document_id = PHPLuceneIndexer::stringToLong($document->DocumentID);
         $coreText = '';
         if ($queryContent) {
             $coreText .= $document->Content;
         }
         if ($queryDiscussion) {
             $coreText .= $document->Discussion;
         }
         $content = $query->highlightMatches($coreText);
         $title = $document->Title;
         $score = $hit->score;
         // avoid adding duplicates. If it is in already, it has higher priority.
         if (!array_key_exists($document_id, $results) || $score > $results[$document_id]->Score) {
             $item = new QueryResultItem($document_id, $score, $title, $content);
             if ($item->CanBeReadByUser) {
                 $results[$document_id] = $item;
             }
         }
     }
     return $results;
 }
开发者ID:sfsergey,项目名称:knowledgetree,代码行数:36,代码来源:PHPLuceneIndexer.inc.php

示例14: initLuceneEngine

 protected function initLuceneEngine()
 {
     $this->load->library('zend', 'Zend/Search/Lucene');
     $this->load->library('zend');
     $this->zend->load('Zend/Search/Lucene');
     Zend_Search_Lucene::setDefaultSearchField('content');
 }
开发者ID:cyberformed,项目名称:i2tree,代码行数:7,代码来源:search_engine_model.php

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


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