• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Zend_Search_Lucene_Search_QueryHit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getDocument

 /**
  * Return the associated index document
  * 
  * @return \Tollwerk\TwLucenesearch\Domain\Model\Document 			Associated index document
  * @see \Zend_Search_Lucene_Search_QueryHit::getDocument()
  */
 public function getDocument()
 {
     if (!$this->_document instanceof \Tollwerk\TwLucenesearch\Domain\Model\Document) {
         $this->_document = \Tollwerk\TwLucenesearch\Domain\Model\Document::cast(parent::getDocument());
     }
     return $this->_document;
 }
开发者ID:GerDner,项目名称:TYPO3-ext-tw_lucenesearch,代码行数:13,代码来源:QueryHit.php


示例2: find

 public function find($query)
 {
     if (is_string($query)) {
         $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
     }
     if (!$query instanceof Zend_Search_Lucene_Search_Query) {
         require_once 'Zend/Search/Lucene/Exception.php';
         throw new Zend_Search_Lucene_Exception('Query must be a string or Zend_Search_Lucene_Search_Query object');
     }
     $this->commit();
     $hits = array();
     $scores = array();
     $ids = array();
     $query = $query->rewrite($this)->optimize($this);
     $query->execute($this);
     $topScore = 0;
     foreach ($query->matchedDocs() as $id => $num) {
         $docScore = $query->score($id, $this);
         if ($docScore != 0) {
             $hit = new Zend_Search_Lucene_Search_QueryHit($this);
             $hit->id = $id;
             $hit->score = $docScore;
             $hits[] = $hit;
             $ids[] = $id;
             $scores[] = $docScore;
             if ($docScore > $topScore) {
                 $topScore = $docScore;
             }
         }
         if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) {
             break;
         }
     }
     if (count($hits) == 0) {
         // skip sorting, which may cause a error on empty index
         return array();
     }
     if ($topScore > 1) {
         foreach ($hits as $hit) {
             $hit->score /= $topScore;
         }
     }
     if (func_num_args() == 1) {
         // sort by scores
         array_multisort($scores, SORT_DESC, SORT_NUMERIC, $ids, SORT_ASC, SORT_NUMERIC, $hits);
     } else {
         // sort by given field names
         $argList = func_get_args();
         $fieldNames = $this->getFieldNames();
         $sortArgs = array();
         require_once 'Zend/Search/Lucene/Exception.php';
         for ($count = 1; $count < count($argList); $count++) {
             $fieldName = $argList[$count];
             if (!is_string($fieldName)) {
                 throw new Zend_Search_Lucene_Exception('Field name must be a string.');
             }
             if (!in_array($fieldName, $fieldNames)) {
                 throw new Zend_Search_Lucene_Exception('Wrong field name.');
             }
             $valuesArray = array();
             foreach ($hits as $hit) {
                 try {
                     $value = $hit->getDocument()->getFieldValue($fieldName);
                 } catch (Zend_Search_Lucene_Exception $e) {
                     if (strpos($e->getMessage(), 'not found') === false) {
                         throw $e;
                     } else {
                         $value = null;
                     }
                 }
                 $valuesArray[] = $value;
             }
             $sortArgs[] = $valuesArray;
             if ($count + 1 < count($argList) && is_integer($argList[$count + 1])) {
                 $count++;
                 $sortArgs[] = $argList[$count];
                 if ($count + 1 < count($argList) && is_integer($argList[$count + 1])) {
                     $count++;
                     $sortArgs[] = $argList[$count];
                 } else {
                     if ($argList[$count] == SORT_ASC || $argList[$count] == SORT_DESC) {
                         $sortArgs[] = SORT_REGULAR;
                     } else {
                         $sortArgs[] = SORT_ASC;
                     }
                 }
             } else {
                 $sortArgs[] = SORT_ASC;
                 $sortArgs[] = SORT_REGULAR;
             }
         }
         // Sort by id's if values are equal
         $sortArgs[] = $ids;
         $sortArgs[] = SORT_ASC;
         $sortArgs[] = SORT_NUMERIC;
         // Array to be sorted
         $sortArgs[] =& $hits;
         // Do sort
         call_user_func_array('array_multisort', $sortArgs);
     }
//.........这里部分代码省略.........
开发者ID:hackingman,项目名称:TubeX,代码行数:101,代码来源:Lucene.php


示例3: 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 Zend_Search_Lucene_Search_QueryParser|string $query
  * @return array Zend_Search_Lucene_Search_QueryHit
  * @throws Zend_Search_Lucene_Exception
  */
 public function find($query)
 {
     if (is_string($query)) {
         // require_once 'Zend/Search/Lucene/Search/QueryParser.php';
         $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
     }
     if (!$query instanceof Zend_Search_Lucene_Search_Query) {
         // require_once 'Zend/Search/Lucene/Exception.php';
         throw new Zend_Search_Lucene_Exception('Query must be a string or Zend_Search_Lucene_Search_Query object');
     }
     $this->commit();
     $hits = array();
     $scores = array();
     $ids = array();
     $query = $query->rewrite($this)->optimize($this);
     $query->execute($this);
     $topScore = 0;
     /** Zend_Search_Lucene_Search_QueryHit */
     // require_once 'Zend/Search/Lucene/Search/QueryHit.php';
     foreach ($query->matchedDocs() as $id => $num) {
         $docScore = $query->score($id, $this);
         if ($docScore != 0) {
             $hit = new Zend_Search_Lucene_Search_QueryHit($this);
             $hit->id = $id;
             $hit->score = $docScore;
             $hits[] = $hit;
             $ids[] = $id;
             $scores[] = $docScore;
             if ($docScore > $topScore) {
                 $topScore = $docScore;
             }
         }
         if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) {
             break;
         }
     }
     if (count($hits) == 0) {
         // skip sorting, which may cause a error on empty index
         return array();
     }
     if ($topScore > 1) {
         foreach ($hits as $hit) {
             $hit->score /= $topScore;
         }
     }
     if (func_num_args() == 1) {
         // sort by scores
         array_multisort($scores, SORT_DESC, SORT_NUMERIC, $ids, SORT_ASC, SORT_NUMERIC, $hits);
     } else {
         // sort by given field names
         $argList = func_get_args();
         $fieldNames = $this->getFieldNames();
         $sortArgs = array();
         // PHP 5.3 now expects all arguments to array_multisort be passed by
         // reference (if it's invoked through call_user_func_array());
         // since constants can't be passed by reference, create some placeholder variables.
         $sortReg = SORT_REGULAR;
         $sortAsc = SORT_ASC;
         $sortNum = SORT_NUMERIC;
         $sortFieldValues = array();
         // require_once 'Zend/Search/Lucene/Exception.php';
         for ($count = 1; $count < count($argList); $count++) {
             $fieldName = $argList[$count];
             if (!is_string($fieldName)) {
                 throw new Zend_Search_Lucene_Exception('Field name must be a string.');
             }
             if (strtolower($fieldName) == 'score') {
                 $sortArgs[] =& $scores;
             } else {
                 if (!in_array($fieldName, $fieldNames)) {
                     throw new Zend_Search_Lucene_Exception('Wrong field name.');
                 }
                 if (!isset($sortFieldValues[$fieldName])) {
                     $valuesArray = array();
                     foreach ($hits as $hit) {
                         try {
                             $value = $hit->getDocument()->getFieldValue($fieldName);
                         } catch (Zend_Search_Lucene_Exception $e) {
                             if (strpos($e->getMessage(), 'not found') === false) {
                                 throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                             } else {
                                 $value = null;
                             }
                         }
                         $valuesArray[] = $value;
                     }
                     // Collect loaded values in $sortFieldValues
                     // Required for PHP 5.3 which translates references into values when source
                     // variable is destroyed
                     $sortFieldValues[$fieldName] = $valuesArray;
                 }
//.........这里部分代码省略.........
开发者ID:alefernie,项目名称:intranet,代码行数:101,代码来源:Lucene.php


示例4: getHitProperties

 /**
  * Get twig properties for matching search document.
  *
  * @param Zend_Search_Lucene_Search_QueryHit $hit
  * @return array
  */
 public function getHitProperties(Zend_Search_Lucene_Search_QueryHit $hit)
 {
     $r = $this->getRequest();
     $snippet = Curry_String::toInternalEncoding($hit->body, 'utf-8');
     $snippet = self::createSearchSnippet($snippet, $r->get['query'], $this->snippetLength);
     $relatedObject = null;
     $model = Curry_String::toInternalEncoding($hit->model, 'utf-8');
     $fields = array();
     foreach ($hit->getDocument()->getFieldNames() as $fieldName) {
         $fields[$fieldName] = $hit->{$fieldName};
     }
     return array('Title' => Curry_String::toInternalEncoding($hit->title, 'utf-8'), 'Description' => Curry_String::toInternalEncoding($hit->description, 'utf-8'), 'Url' => Curry_String::toInternalEncoding($hit->url, 'utf-8'), 'Snippet' => $snippet, 'Score' => $hit->score, 'Fields' => $fields, 'RelatedObject' => new Curry_OnDemand(array($this, 'getRelatedObject'), $model, unserialize($hit->model_id)));
 }
开发者ID:varvanin,项目名称:currycms,代码行数:19,代码来源:Search.php


示例5: find

 public function find($query)
 {
     if (is_string($query)) {
         $query = Zend_Search_Lucene_Search_QueryParser::parse($query);
     }
     if (!$query instanceof Zend_Search_Lucene_Search_Query) {
         throw new Zend_Search_Lucene_Exception('Query must be a string or Zend_Search_Lucene_Search_Query object');
     }
     $this->commit();
     $hits = array();
     $scores = array();
     $ids = array();
     $query = $query->rewrite($this)->optimize($this);
     $query->execute($this);
     $topScore = 0;
     foreach ($query->matchedDocs() as $id => $num) {
         $docScore = $query->score($id, $this);
         if ($docScore != 0) {
             $hit = new Zend_Search_Lucene_Search_QueryHit($this);
             $hit->id = $id;
             $hit->score = $docScore;
             $hits[] = $hit;
             $ids[] = $id;
             $scores[] = $docScore;
             if ($docScore > $topScore) {
                 $topScore = $docScore;
             }
         }
         if (self::$_resultSetLimit != 0 && count($hits) >= self::$_resultSetLimit) {
             break;
         }
     }
     if (count($hits) == 0) {
         return array();
     }
     if ($topScore > 1) {
         foreach ($hits as $hit) {
             $hit->score /= $topScore;
         }
     }
     if (func_num_args() == 1) {
         array_multisort($scores, SORT_DESC, SORT_NUMERIC, $ids, SORT_ASC, SORT_NUMERIC, $hits);
     } else {
         $argList = func_get_args();
         $fieldNames = $this->getFieldNames();
         $sortArgs = array();
         $sortReg = SORT_REGULAR;
         $sortAsc = SORT_ASC;
         $sortNum = SORT_NUMERIC;
         $sortFieldValues = array();
         for ($count = 1; $count < count($argList); $count++) {
             $fieldName = $argList[$count];
             if (!is_string($fieldName)) {
                 throw new Zend_Search_Lucene_Exception('Field name must be a string.');
             }
             if (strtolower($fieldName) == 'score') {
                 $sortArgs[] =& $scores;
             } else {
                 if (!in_array($fieldName, $fieldNames)) {
                     throw new Zend_Search_Lucene_Exception('Wrong field name.');
                 }
                 if (!isset($sortFieldValues[$fieldName])) {
                     $valuesArray = array();
                     foreach ($hits as $hit) {
                         try {
                             $value = $hit->getDocument()->getFieldValue($fieldName);
                         } catch (Zend_Search_Lucene_Exception $e) {
                             if (strpos($e->getMessage(), 'not found') === false) {
                                 throw new Zend_Search_Lucene_Exception($e->getMessage(), $e->getCode(), $e);
                             } else {
                                 $value = null;
                             }
                         }
                         $valuesArray[] = $value;
                     }
                     $sortFieldValues[$fieldName] = $valuesArray;
                 }
                 $sortArgs[] =& $sortFieldValues[$fieldName];
             }
             if ($count + 1 < count($argList) && is_integer($argList[$count + 1])) {
                 $count++;
                 $sortArgs[] =& $argList[$count];
                 if ($count + 1 < count($argList) && is_integer($argList[$count + 1])) {
                     $count++;
                     $sortArgs[] =& $argList[$count];
                 } else {
                     if ($argList[$count] == SORT_ASC || $argList[$count] == SORT_DESC) {
                         $sortArgs[] =& $sortReg;
                     } else {
                         $sortArgs[] =& $sortAsc;
                     }
                 }
             } else {
                 $sortArgs[] =& $sortAsc;
                 $sortArgs[] =& $sortReg;
             }
         }
         $sortArgs[] =& $ids;
         $sortArgs[] =& $sortAsc;
         $sortArgs[] =& $sortNum;
//.........这里部分代码省略.........
开发者ID:Blu2z,项目名称:implsk,代码行数:101,代码来源:Zend_Search_Lucene.php


示例6: getHitProperties

 /**
  * Get twig properties for matching search document.
  *
  * @param \Zend_Search_Lucene_Search_QueryHit $hit
  * @return array
  */
 public function getHitProperties(\Zend_Search_Lucene_Search_QueryHit $hit)
 {
     $r = $this->app->request;
     $snippet = self::createSearchSnippet($hit->body, $r->query->get('query'), $this->snippetLength);
     $fields = array();
     foreach ($hit->getDocument()->getFieldNames() as $fieldName) {
         $fields[$fieldName] = $hit->{$fieldName};
     }
     return array('Title' => $hit->title, 'Description' => $hit->description, 'Url' => $hit->url, 'Snippet' => $snippet, 'Score' => $hit->score, 'Fields' => $fields, 'RelatedObject' => new OnDemand(array($this, 'getRelatedObject'), $hit->model, unserialize($hit->model_id)));
 }
开发者ID:bombayworks,项目名称:currycms,代码行数:16,代码来源:Search.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Zend_Search_Lucene_Search_QueryParser类代码示例发布时间:2022-05-23
下一篇:
PHP Zend_Search_Lucene_Search_Query类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap