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


PHP Zend_Search_Lucene_Interface::find方法代碼示例

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


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

示例1: find

 /**
  * Search into files
  *
  * @param   string      $query      The query
  * @return  array                   The file list
  */
 public function find($query)
 {
     $result = array();
     $hits = $this->_data->find($query);
     foreach ($hits as $hit) {
         $document = $hit->getDocument();
         $result[] = $document->path;
     }
     return $result;
 }
開發者ID:neolao,項目名稱:wiki,代碼行數:16,代碼來源:Search.php

示例2: get_similar_posts

 /**
  * Return a list of posts that are similar to the current post.
  * This is not a very good implementation, so do not expect 
  * amazing results - the term vector is not available for a doc
  * in ZSL, which limits how far you can go!
  *
  * @return array ids 
  */
 public function get_similar_posts($post, $max_recommended = 5)
 {
     Zend_Search_Lucene::setResultSetLimit($max_recommended + 1);
     $title = $post->title;
     $tags = $post->tags;
     $tagstring = '';
     foreach ($tags as $tag) {
         $tagstring .= $tag . ' ';
     }
     $analyser = Zend_Search_Lucene_Analysis_Analyzer::getDefault();
     $tokens = $analyser->tokenize(strtolower($tagstring) . ' ' . strtolower($title));
     $query = new Zend_Search_Lucene_Search_Query_MultiTerm();
     foreach ($tokens as $token) {
         $query->addTerm(new Zend_Search_Lucene_Index_Term($token->getTermText()));
     }
     $hits = $this->_index->find($query);
     $ids = array();
     $counter = 0;
     foreach ($hits as $hit) {
         if ($hit->postid != $post->id) {
             $ids[] = $hit->postid;
             $counter++;
         }
         if ($counter == $max_recommended) {
             break;
         }
     }
     return $ids;
 }
開發者ID:habari-extras,項目名稱:multisearch,代碼行數:37,代碼來源:zendsearchlucene.php

示例3: search

 /**
  * Execute the query
  *
  * @param string|Zym_Search_Lucene_IQuery $query
  * @param int $resultSetLimit
  * @return array
  */
 public function search($query, $resultSetLimit = null)
 {
     if (!$resultSetLimit) {
         $resultSetLimit = self::$_defaultResultSetLimit;
     }
     Zend_Search_Lucene::setResultSetLimit((int) $resultSetLimit);
     return $this->_searchIndex->find((string) $query);
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:15,代碼來源:Index.php

示例4: removeFromIndex

 public static function removeFromIndex($term)
 {
     $websiteHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('website');
     $searchIndexFolder = $websiteHelper->getPath() . 'cache/' . Widgets_Search_Search::INDEX_FOLDER;
     if (!is_dir($searchIndexFolder)) {
         return false;
     }
     if (!self::initIndex()) {
         return false;
     }
     $hits = self::$_index->find(strval($term));
     if (is_array($hits) && !empty($hits)) {
         foreach ($hits as $hit) {
             self::$_index->delete($hit->id);
         }
         return true;
     }
     return false;
 }
開發者ID:PavloKovalov,項目名稱:seotoaster,代碼行數:19,代碼來源:Tools.php

示例5: query

 /**
  * Find, format, return results
  *
  * @param \Zend_Search_Lucene_Interface $index
  * @param string $query
  * @return array
  */
 public function query(\Zend_Search_Lucene_Interface $index, $query)
 {
     $preparedQuery = $this->prepareQuery($query);
     $q = Parser::parse($preparedQuery);
     /* @var $hits \Zend_Search_Lucene_Search_QueryHit[] */
     $hits = $index->find($q, 'type', SORT_REGULAR, SORT_DESC);
     // if no hits are found with an exact phrase, fall back to token search
     if (count($hits) === 0) {
         $q = Parser::parse($query);
         $hits = $index->find($q, 'type', SORT_REGULAR, SORT_ASC);
     }
     $results = array();
     foreach ($hits as $hit) {
         $h = array();
         $h['title'] = $hit->getDocument()->getFieldValue('title');
         $h['url'] = $hit->getDocument()->getFieldValue('url');
         $h['score'] = $hit->score;
         $h['type'] = $hit->getDocument()->getFieldValue('type');
         $results[] = $h;
     }
     return $results;
 }
開發者ID:abouthalf,項目名稱:archies-recipes,代碼行數:29,代碼來源:SearchProvider.php

示例6: find

 /**
  * Performs a query against the index and returns an array
  * of Zend_Search_Lucene_Search_QueryHit objects.
  * Input is a string or Zend_Search_Lucene_Search_Query.
  *
  * @param mixed $query
  * @return array Zend_Search_Lucene_Search_QueryHit
  * @throws Zend_Search_Lucene_Exception
  */
 public function find($query)
 {
     return $this->_index->find($query);
 }
開發者ID:josephholsten,項目名稱:swaplady,代碼行數:13,代碼來源:Proxy.php

示例7: getIndexedChildrenDocuments

 /**
  * Find all existing lucene documents based on the parent url
  * @param Zend_Search_Lucene_Interface $index
  * @param AJXP_Node $ajxpNode
  * @return Zend_Search_Lucene_Search_QueryHit
  */
 public function getIndexedChildrenDocuments($index, $ajxpNode)
 {
     // Try getting doc by url
     $testQ = str_replace("/", "AJXPFAKESEP", SystemTextEncoding::toUTF8($ajxpNode->getPath()));
     $pattern = new Zend_Search_Lucene_Index_Term($testQ . '*', 'node_path');
     $query = new Zend_Search_Lucene_Search_Query_Wildcard($pattern);
     $hits = $index->find($query);
     return $hits;
 }
開發者ID:thermalpaste,項目名稱:pydio-core,代碼行數:15,代碼來源:class.AjxpLuceneIndexer.php

示例8: fuzzyFindTerms

 /**
  *  finds similar terms
  * @param string $queryStr
  * @param \Zend_Search_Lucene_Interface $index
  * @param integer $prefixLength optionally specify prefix length, default 0
  * @param float $similarity optionally specify similarity, default 0.5
  * @return string[] $similarSearchTerms
  */
 public static function fuzzyFindTerms($queryStr, $index, $prefixLength = 0, $similarity = 0.5)
 {
     if ($index != NULL) {
         \Zend_Search_Lucene_Search_Query_Fuzzy::setDefaultPrefixLength($prefixLength);
         $term = new \Zend_Search_Lucene_Index_Term($queryStr);
         $fuzzyQuery = new \Zend_Search_Lucene_Search_Query_Fuzzy($term, $similarity);
         $hits = $index->find($fuzzyQuery);
         $terms = $fuzzyQuery->getQueryTerms();
         return $terms;
     }
 }
開發者ID:dachcom-digital,項目名稱:pimcore-lucene-search,代碼行數:19,代碼來源:Plugin.php

示例9: _executeSearch

 /**
  * Execute the search and return the results
  *
  * @param string|Zym_Search_Lucene_IQuery $query
  * @return array
  */
 protected function _executeSearch($query)
 {
     return $this->_searchIndex->find((string) $query);
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:10,代碼來源:Index.php


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