File indexing completed on 2024-06-23 05:55:39
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Search_Lucene 0017 * @subpackage Search 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 0024 /** 0025 * @category Zend 0026 * @package Zend_Search_Lucene 0027 * @subpackage Search 0028 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0029 * @license http://framework.zend.com/license/new-bsd New BSD License 0030 */ 0031 class Zend_Search_Lucene_Search_QueryHit 0032 { 0033 /** 0034 * Object handle of the index 0035 * @var Zend_Search_Lucene_Interface 0036 */ 0037 protected $_index = null; 0038 0039 /** 0040 * Object handle of the document associated with this hit 0041 * @var Zend_Search_Lucene_Document 0042 */ 0043 protected $_document = null; 0044 0045 /** 0046 * Number of the document in the index 0047 * @var integer 0048 */ 0049 public $id; 0050 0051 /** 0052 * Score of the hit 0053 * @var float 0054 */ 0055 public $score; 0056 0057 0058 /** 0059 * Constructor - pass object handle of Zend_Search_Lucene_Interface index that produced 0060 * the hit so the document can be retrieved easily from the hit. 0061 * 0062 * @param Zend_Search_Lucene_Interface $index 0063 */ 0064 0065 public function __construct(Zend_Search_Lucene_Interface $index) 0066 { 0067 // require_once 'Zend/Search/Lucene/Proxy.php'; 0068 $this->_index = new Zend_Search_Lucene_Proxy($index); 0069 } 0070 0071 0072 /** 0073 * Convenience function for getting fields from the document 0074 * associated with this hit. 0075 * 0076 * @param string $offset 0077 * @return string 0078 */ 0079 public function __get($offset) 0080 { 0081 return $this->getDocument()->getFieldValue($offset); 0082 } 0083 0084 0085 /** 0086 * Return the document object for this hit 0087 * 0088 * @return Zend_Search_Lucene_Document 0089 */ 0090 public function getDocument() 0091 { 0092 if (!$this->_document instanceof Zend_Search_Lucene_Document) { 0093 $this->_document = $this->_index->getDocument($this->id); 0094 } 0095 0096 return $this->_document; 0097 } 0098 0099 0100 /** 0101 * Return the index object for this hit 0102 * 0103 * @return Zend_Search_Lucene_Interface 0104 */ 0105 public function getIndex() 0106 { 0107 return $this->_index; 0108 } 0109 } 0110