Subversion-Projekte lars-tiefland.prado

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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