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: Phrase.php 16541 2009-07-07 06:59:03Z bkarwin $
25 * Zend_Search_Lucene_Search_Weight
27 require_once 'Zend/Search/Lucene/Search/Weight.php';
32 * @package Zend_Search_Lucene
34 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
35 * @license http://framework.zend.com/license/new-bsd New BSD License
37 class Zend_Search_Lucene_Search_Weight_Phrase extends Zend_Search_Lucene_Search_Weight
42 * @var Zend_Search_Lucene_Interface
47 * The query that this concerns.
49 * @var Zend_Search_Lucene_Search_Query_Phrase
61 * Zend_Search_Lucene_Search_Weight_Phrase constructor
63 * @param Zend_Search_Lucene_Search_Query_Phrase $query
64 * @param Zend_Search_Lucene_Interface $reader
66 public function __construct(Zend_Search_Lucene_Search_Query_Phrase $query,
67 Zend_Search_Lucene_Interface $reader)
69 $this->_query = $query;
70 $this->_reader = $reader;
74 * The sum of squared weights of contained query clauses.
78 public function sumOfSquaredWeights()
81 $this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader);
83 // compute query weight
84 $this->_queryWeight = $this->_idf * $this->_query->getBoost();
87 return $this->_queryWeight * $this->_queryWeight;
92 * Assigns the query normalization factor to this.
94 * @param float $queryNorm
96 public function normalize($queryNorm)
98 $this->_queryNorm = $queryNorm;
100 // normalize query weight
101 $this->_queryWeight *= $queryNorm;
104 $this->_value = $this->_queryWeight * $this->_idf;