当前位置: 首页>>代码示例>>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;未经允许,请勿转载。