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.
16 * @package Zend_Search_Lucene
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Term.php 16541 2009-07-07 06:59:03Z bkarwin $
24 /** Zend_Search_Lucene_Search_Weight */
25 require_once 'Zend/Search/Lucene/Search/Weight.php';
30 * @package Zend_Search_Lucene
32 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
33 * @license http://framework.zend.com/license/new-bsd New BSD License
35 class Zend_Search_Lucene_Search_Weight_Term extends Zend_Search_Lucene_Search_Weight
40 * @var Zend_Search_Lucene_Interface
47 * @var Zend_Search_Lucene_Index_Term
52 * The query that this concerns.
54 * @var Zend_Search_Lucene_Search_Query
70 private $_queryWeight;
74 * Zend_Search_Lucene_Search_Weight_Term constructor
75 * reader - index reader
77 * @param Zend_Search_Lucene_Index_Term $term
78 * @param Zend_Search_Lucene_Search_Query $query
79 * @param Zend_Search_Lucene_Interface $reader
81 public function __construct(Zend_Search_Lucene_Index_Term $term,
82 Zend_Search_Lucene_Search_Query $query,
83 Zend_Search_Lucene_Interface $reader)
86 $this->_query = $query;
87 $this->_reader = $reader;
92 * The sum of squared weights of contained query clauses.
96 public function sumOfSquaredWeights()
99 $this->_idf = $this->_reader->getSimilarity()->idf($this->_term, $this->_reader);
101 // compute query weight
102 $this->_queryWeight = $this->_idf * $this->_query->getBoost();
105 return $this->_queryWeight * $this->_queryWeight;
110 * Assigns the query normalization factor to this.
112 * @param float $queryNorm
114 public function normalize($queryNorm)
116 $this->_queryNorm = $queryNorm;
118 // normalize query weight
119 $this->_queryWeight *= $queryNorm;
122 $this->_value = $this->_queryWeight * $this->_idf;