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


PHP Zend_Search_Lucene::find方法代码示例

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


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

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

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

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

示例4: indexationSearch

 public static function indexationSearch($searchParams)
 {
     Zend_Search_Lucene::setDefaultSearchField('contents');
     $directory = Zend_Registry::get('lucene_index');
     $index = new Zend_Search_Lucene($directory);
     $words = strtolower(Cible_FunctionsGeneral::removeAccents(Cible_FunctionsGeneral::html2text(utf8_decode($searchParams['words']))));
     $wordsArray = explode(' ', $words);
     if (count($wordsArray) > 1) {
         $query = new Zend_Search_Lucene_Search_Query_Phrase($wordsArray);
     } else {
         if (strlen($words) >= 3) {
             $pattern = new Zend_Search_Lucene_Index_Term("{$words}*");
             $query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
         } else {
             $term = new Zend_Search_Lucene_Index_Term($words);
             $query = new Zend_Search_Lucene_Search_Query_Term($term);
         }
     }
     $hits = $index->find($query);
     //echo($query);
     $i = 0;
     $result = array();
     foreach ($hits as $hit) {
         $result[$i]['moduleID'] = $hit->moduleID;
         $result[$i]['pageID'] = $hit->pageID;
         $result[$i]['contentID'] = $hit->contentID;
         $result[$i]['languageID'] = $hit->languageID;
         $result[$i]['title'] = $hit->title;
         $result[$i]['text'] = $hit->text;
         $result[$i]['link'] = $hit->link;
         $i++;
     }
     return $result;
 }
开发者ID:anunay,项目名称:stentors,代码行数:34,代码来源:FunctionsIndexation.php

示例5: actionIndex

 public function actionIndex()
 {
     $this->webpageType = 'SearchResultsPage';
     $type = '';
     if (isset($_GET['type'])) {
         $type = $_GET['type'];
     }
     if (isset($_GET['q'])) {
         //            $originalQuery = $_GET['q'];
         $queryString = $originalQuery = isset($_GET['q']) ? $_GET['q'] : '';
         $index = new Zend_Search_Lucene($this->_indexFile);
         //only look for queryString in title and content, well if advanced search techniques aren't used
         if (!(strpos(strtolower($queryString), 'and') || strpos(strtolower($queryString), 'or') || strpos(strtolower($queryString), ':'))) {
             $queryString = "title:{$queryString} OR content:{$queryString}";
         }
         if ($type) {
             $queryString .= ' AND type:' . $type;
         }
         $results = $index->find($queryString);
         $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
         $this->render('index', compact('results', 'originalQuery', 'query', 'type'));
     } else {
         $this->render('advanced', array('type' => $type));
     }
 }
开发者ID:awecode,项目名称:awecms,代码行数:25,代码来源:SearchController.php

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

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

示例8: findFuzzy

 /**
  *
  * @return array
  * @param string | Zend_Search_Lucene_Search_Query_Boolean $fuzzyQuery
  */
 public function findFuzzy($fuzzyQuery)
 {
     if (!is_string($fuzzyQuery)) {
         $fuzzyQuery = $fuzzyQuery->__toString();
     }
     $result = array();
     foreach ($this->_index->find($fuzzyQuery) as $hit) {
         $result[] = $hit->id;
     }
     return $result;
 }
开发者ID:rommmka,项目名称:axiscommerce,代码行数:16,代码来源:Lucene.php

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

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

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

示例12: indexAction

 public function indexAction()
 {
     if ($this->hasParam('text')) {
         $userQuery = Zend_Search_Lucene_Search_QueryParser::parse($this->getParam('text'));
         $hits = $this->_indexHandle->find($userQuery);
         $result = array();
         foreach ($hits as $hit) {
             if (mb_strlen($hit->content) > 200) {
                 $firstWord = current(explode(' ', $this->getParam('text')));
                 $posWord = mb_strpos($hit->content, $firstWord);
                 $before = mb_substr($hit->content, $posWord - 100, 100);
                 // 20 символов до слова
                 $after = mb_substr($hit->content, $posWord, 100);
                 // 100 символов после слова
                 $text = '...' . $before . $after . '...';
             } else {
                 $text = $hit->content;
             }
             array_push($result, array('title' => $hit->title, 'url' => $hit->url, 'content' => $userQuery->htmlFragmentHighlightMatches($text)));
         }
         $this->view->result = $result;
     }
     $this->view->text = $this->getParam('text');
 }
开发者ID:kytvi2p,项目名称:ZettaFramework,代码行数:24,代码来源:IndexController.php

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

示例14: 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();
         }
     }
     $params = JComponentHelper::getParams('com_search_lucene');
     $indexpath = $params->get('indexpath');
     $pluginindex = $indexpath . DS . $this->pluginName;
     $index = new Zend_Search_Lucene($pluginindex);
     if ($index) {
         $rows = $index->find($text);
     } else {
         $rows = array();
     }
     return $rows;
 }
开发者ID:beingsane,项目名称:com-search-lucene,代码行数:18,代码来源:search_lucene_sobi2.php

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


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