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


PHP Zend_Search_Lucene_Search_QueryParser::parse方法代碼示例

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


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

示例1: useSearchIndex

 protected function useSearchIndex($slug)
 {
     if (!dmConfig::get('smart_404')) {
         return false;
     }
     try {
         $searchIndex = $this->serviceContainer->get('search_engine')->getCurrentIndex();
         $queryString = str_replace('/', ' ', dmString::unSlugify($slug));
         $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
         $results = $searchIndex->search($query);
         $foundPage = null;
         foreach ($results as $result) {
             if ($result->getScore() > 0.5) {
                 if ($foundPage = $result->getPage()) {
                     break;
                 }
             } else {
                 break;
             }
         }
         if ($foundPage) {
             return $this->serviceContainer->getService('helper')->link($foundPage)->getHref();
         }
     } catch (Exception $e) {
         $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Can not use search index to find redirection for slug ' . $slug, sfLogger::ERR)));
         if (sfConfig::get('dm_debug')) {
             throw $e;
         }
     }
 }
開發者ID:jdart,項目名稱:diem,代碼行數:30,代碼來源:dmPageNotFoundHandler.php

示例2: searchLuceneWithValues

 public static function searchLuceneWithValues(Doctrine_Table $table, $luceneQueryString, $culture = null)
 {
     // Ugh: UTF8 Lucene is case sensitive work around this
     if (function_exists('mb_strtolower')) {
         $luceneQueryString = mb_strtolower($luceneQueryString);
     } else {
         $luceneQueryString = strtolower($luceneQueryString);
     }
     // We have to register the autoloader before we can use these classes
     self::registerZend();
     $luceneQuery = Zend_Search_Lucene_Search_QueryParser::parse($luceneQueryString);
     $query = new Zend_Search_Lucene_Search_Query_Boolean();
     $query->addSubquery($luceneQuery, true);
     if (!is_null($culture)) {
         $culture = self::normalizeCulture($culture);
         $cultureTerm = new Zend_Search_Lucene_Index_Term($culture, 'culture');
         // Oops, this said $aTerm before. Thanks to Quentin Dugauthier
         $cultureQuery = new Zend_Search_Lucene_Search_Query_Term($cultureTerm);
         $query->addSubquery($cultureQuery, true);
     }
     $index = $table->getLuceneIndex();
     $hits = $index->find($query);
     $ids = array();
     foreach ($hits as $hit) {
         $ids[$hit->primarykey] = $hit;
     }
     return $ids;
 }
開發者ID:quafzi,項目名稱:timpany-prototype,代碼行數:28,代碼來源:aZendSearch.class.php

示例3: search

 /**
  * Method to perform a search. This function returns results from Zend_Lucene_Search
  * and is unpolished as it doesn't check permission issues, etc.
  * 
  * @access private
  * @param string $text Text to search for
  * @param string $module Module to search items for
  * @param string $context Context in which to search
  * @param array $extra Any additional items
  * @return object
  */
 private function search($text, $module = NULL, $context = NULL, $extra = array())
 {
     $objIndexData = $this->getObject('indexdata');
     $indexer = $objIndexData->checkIndexPath();
     // Some cllean up till we can find a better way
     $phrase = trim(str_replace(':', ' ', $text));
     $phrase = trim(str_replace('+', ' ', $phrase));
     $phrase = trim(str_replace('-', ' ', $phrase));
     if ($module != NULL) {
         if ($text != '') {
             $phrase .= ' AND ';
         }
         $phrase .= ' module:' . $module . ' ';
     }
     if ($context != NULL) {
         if ($phrase != '') {
             $phrase .= ' AND ';
         }
         $phrase .= ' context:' . $context . ' ';
     }
     if (is_array($extra) && count($extra) > 0) {
         foreach ($extra as $item => $value) {
             if ($phrase != '') {
                 $phrase .= ' AND ';
             }
             $phrase .= $item . ':' . $value . ' ';
         }
     }
     //echo $phrase;
     $query = Zend_Search_Lucene_Search_QueryParser::parse($phrase);
     return $indexer->find($query);
 }
開發者ID:ookwudili,項目名稱:chisimba,代碼行數:43,代碼來源:searchresults_class_inc.php

示例4: index

 public function index($msg = NULL)
 {
     $results = NULL;
     $results2 = NULL;
     $query = NULL;
     $view = new View('search_example');
     $view->bind("results", $results)->bind("results2", $results2)->bind("query", $query)->bind("msg", $msg);
     if (!empty($_GET["q"])) {
         try {
             $query = $_GET["q"];
             $form = $_GET["form"];
             if ($form == "artists") {
                 $results = Search::instance()->find($query);
             } else {
                 Search::instance()->load_search_libs();
                 $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
                 $hits = Search::instance()->find($query);
                 if (sizeof($hits) > 0) {
                     $results2 = $query->highlightMatches(iconv('UTF-8', 'ASCII//TRANSLIT', $hits[0]->body));
                 } else {
                     $results2 = '<p style="color:#f00">No results found</p>';
                 }
             }
         } catch (Exception $e) {
             Kohana::log("error", $e);
         }
     }
     $view->render(TRUE);
 }
開發者ID:ascseb,項目名稱:kosearch,代碼行數:29,代碼來源:search_example.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: addString

 /**
  * Adds a string that is parsed into Zend API queries
  * @param string $query The query to parse
  * @param string $encoding The encoding to parse query as
  * 
  * @return sfLuceneCriteria
  */
 public function addString($query, $encoding = null, $type = true)
 {
     $this->search->configure();
     // setup query parser
     $this->add(Zend_Search_Lucene_Search_QueryParser::parse($query, $encoding), $type);
     return $this;
 }
開發者ID:palcoprincipal,項目名稱:sfLucenePlugin,代碼行數:14,代碼來源:sfLuceneCriteria.class.php

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

示例8: ZendSearchLuceneResults

 /**
  * Process and render search results. Uses the Lucene_results.ss template to
  * render the form.
  * 
  * @access public
  * @param   array           $data       The raw request data submitted by user
  * @param   Form            $form       The form instance that was submitted
  * @param   SS_HTTPRequest  $request    Request generated for this action
  * @return  String                      The rendered form, for inclusion into the page template.
  */
 public function ZendSearchLuceneResults($data, $form, $request)
 {
     $querystring = $form->Fields()->dataFieldByName('Search')->dataValue();
     $query = Zend_Search_Lucene_Search_QueryParser::parse($querystring);
     $hits = ZendSearchLuceneWrapper::find($query);
     $data = $this->getDataArrayFromHits($hits, $request);
     return $this->owner->customise($data)->renderWith(array('Lucene_results', 'Page'));
 }
開發者ID:helpfulrobot,項目名稱:asecondwill-lucene,代碼行數:18,代碼來源:ZendSearchLuceneContentController.php

示例9: searchTag

 public function searchTag($tag, $value)
 {
     if (!$this->_enabled) {
         return array();
     }
     Zend_Search_Lucene::setDefaultSearchField($tag);
     $query = Zend_Search_Lucene_Search_QueryParser::parse($value);
     return $this->_index->find($query);
 }
開發者ID:ntulip,項目名稱:joobsbox-php,代碼行數:9,代碼來源:Search.php

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

示例11: parse

 public function parse($query)
 {
     $query = Zend_Search_Lucene_Search_QueryParser::parse($query, 'UTF-8');
     if ($query instanceof Zend_Search_Lucene_Search_Query_Insignificant) {
         throw new Exception('No search terms specified.');
     } elseif ($query instanceof Zend_Search_Lucene_Search_Query_MultiTerm) {
         throw new Exception('Error parsing search terms.');
     }
     return $query;
 }
開發者ID:nurfiantara,項目名稱:ehri-ica-atom,代碼行數:10,代碼來源:QubitSearch.class.php

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

示例13: testQueryParser

 public function testQueryParser()
 {
     $queries = array('title:"The Right Way" AND text:go', 'title:"Do it right" AND right', 'title:Do it right', '"jakarta apache"~10', 'jakarta apache', 'jakarta^4 apache', '"jakarta apache"^4 "Apache Lucene"', '"jakarta apache" jakarta', '"jakarta apache" OR jakarta', '"jakarta apache" || jakarta', '"jakarta apache" AND "Apache Lucene"', '"jakarta apache" && "Apache Lucene"', '+jakarta apache', '"jakarta apache" AND NOT "Apache Lucene"', '"jakarta apache" && !"Apache Lucene"', 'NOT "jakarta apache"', '!"jakarta apache"', '"jakarta apache" -"Apache Lucene"', '(jakarta OR apache) AND website', '(jakarta || apache) && website', 'title:(+return +"pink panther")', 'title:(+re\\turn\\ value +"pink panther\\"" +body:cool)', '+type:1 +id:5', 'type:1 AND id:5', 'f1:word1 f1:word2 and f1:word3', 'f1:word1 not f1:word2 and f1:word3');
     $rewritedQueries = array('+(title:"the right way") +(text:go)', '+(title:"do it right") +(path:right modified:right contents:right)', '(title:do) (path:it modified:it contents:it) (path:right modified:right contents:right)', '((path:"jakarta apache"~10) (modified:"jakarta apache"~10) (contents:"jakarta apache"~10))', '(path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)', '((path:jakarta modified:jakarta contents:jakarta)^4)^4 (path:apache modified:apache contents:apache)', '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache"))^4 ((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) (path:jakarta modified:jakarta contents:jakarta)', '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) +((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) +((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', '+(path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)', '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', '+((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', '<EmptyQuery>', '<EmptyQuery>', '((path:"jakarta apache") (modified:"jakarta apache") (contents:"jakarta apache")) -((path:"apache lucene") (modified:"apache lucene") (contents:"apache lucene"))', '+((path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)) +(path:website modified:website contents:website)', '+((path:jakarta modified:jakarta contents:jakarta) (path:apache modified:apache contents:apache)) +(path:website modified:website contents:website)', '(+(title:return) +(title:"pink panther"))', '(+(+title:return +title:value) +(title:"pink panther") +(body:cool))', '+(<EmptyQuery>) +(<EmptyQuery>)', '+(<EmptyQuery>) +(<EmptyQuery>)', '(f1:word) (+(f1:word) +(f1:word))', '(f1:word) (-(f1:word) +(f1:word))');
     $index = Zend_Search_Lucene::open(dirname(__FILE__) . '/_files/_indexSample');
     foreach ($queries as $id => $queryString) {
         $query = Zend_Search_Lucene_Search_QueryParser::parse($queryString);
         $this->assertTrue($query instanceof Zend_Search_Lucene_Search_Query);
         $this->assertEquals($query->rewrite($index)->__toString(), $rewritedQueries[$id]);
     }
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:11,代碼來源:SearchTest.php

示例14: __construct

 function __construct($query)
 {
     $qstr = $query->__toString();
     // query needs the object_type field removing for highlighting
     $qstr = preg_replace('/\\+?\\(\\(object_type.*?\\)\\)/', '', $qstr);
     // this is the only way i can find to remove a term form a query
     $query = Zend_Search_Lucene_Search_QueryParser::parse($qstr, 'UTF-8');
     // rebuild
     $this->query = $query;
     $this->snippetHelper = new Search_ResultSet_SnippetHelper();
 }
開發者ID:jkimdon,項目名稱:cohomeals,代碼行數:11,代碼來源:HighlightHelper.php

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


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