[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/search/Zend/Search/Lucene/Search/ -> QueryHit.php (source)

   1  <?php
   2  /**
   3   * Zend Framework
   4   *
   5   * LICENSE
   6   *
   7   * This source file is subject to the new BSD license that is bundled
   8   * with this package in the file LICENSE.txt.
   9   * It is also available through the world-wide-web at this URL:
  10   * http://framework.zend.com/license/new-bsd
  11   * If you did not receive a copy of the license and are unable to
  12   * obtain it through the world-wide-web, please send an email
  13   * to license@zend.com so we can send you a copy immediately.
  14   *
  15   * @category   Zend
  16   * @package    Zend_Search_Lucene
  17   * @subpackage Search
  18   * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  19   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  20   */
  21  
  22  
  23  /**
  24   * @category   Zend
  25   * @package    Zend_Search_Lucene
  26   * @subpackage Search
  27   * @copyright  Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com)
  28   * @license    http://framework.zend.com/license/new-bsd     New BSD License
  29   */
  30  class Zend_Search_Lucene_Search_QueryHit
  31  {
  32      /**
  33       * Object handle of the index
  34       * @var Zend_Search_Lucene_Interface
  35       */
  36      protected $_index = null;
  37  
  38      /**
  39       * Object handle of the document associated with this hit
  40       * @var Zend_Search_Lucene_Document
  41       */
  42      protected $_document = null;
  43  
  44      /**
  45       * Number of the document in the index
  46       * @var integer
  47       */
  48      public $id;
  49  
  50      /**
  51       * Score of the hit
  52       * @var float
  53       */
  54      public $score;
  55  
  56  
  57      /**
  58       * Constructor - pass object handle of Zend_Search_Lucene_Interface index that produced
  59       * the hit so the document can be retrieved easily from the hit.
  60       *
  61       * @param Zend_Search_Lucene_Interface $index
  62       */
  63  
  64      public function __construct(Zend_Search_Lucene_Interface $index)
  65      {
  66          $this->_index = new Zend_Search_Lucene_Proxy($index);
  67      }
  68  
  69  
  70      /**
  71       * Convenience function for getting fields from the document
  72       * associated with this hit.
  73       *
  74       * @param string $offset
  75       * @return string
  76       */
  77      public function __get($offset)
  78      {
  79          return $this->getDocument()->getFieldValue($offset);
  80      }
  81  
  82  
  83      /**
  84       * Return the document object for this hit
  85       *
  86       * @return Zend_Search_Lucene_Document
  87       */
  88      public function getDocument()
  89      {
  90          if (!$this->_document instanceof Zend_Search_Lucene_Document) {
  91              $this->_document = $this->_index->getDocument($this->id);
  92          }
  93  
  94          return $this->_document;
  95      }
  96  
  97  
  98      /**
  99       * Return the index object for this hit
 100       *
 101       * @return Zend_Search_Lucene_Interface
 102       */
 103      public function getIndex()
 104      {
 105          return $this->_index;
 106      }
 107  }
 108  


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7