import
[web.mtrack] / inc / lib / Zend / Search / Lucene / Search / Weight.php
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-2009 Zend Technologies USA Inc. (http://www.zend.com)
19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
20  * @version    $Id: Weight.php 16541 2009-07-07 06:59:03Z bkarwin $
21  */
22
23
24 /**
25  * Calculate query weights and build query scorers.
26  *
27  * A Weight is constructed by a query Query->createWeight().
28  * The sumOfSquaredWeights() method is then called on the top-level
29  * query to compute the query normalization factor Similarity->queryNorm(float).
30  * This factor is then passed to normalize(float).  At this point the weighting
31  * is complete.
32  *
33  * @category   Zend
34  * @package    Zend_Search_Lucene
35  * @subpackage Search
36  * @copyright  Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
38  */
39 abstract class Zend_Search_Lucene_Search_Weight
40 {
41     /**
42      * Normalization factor.
43      * This value is stored only for query expanation purpose and not used in any other place
44      *
45      * @var float
46      */
47     protected $_queryNorm;
48
49     /**
50      * Weight value
51      *
52      * Weight value may be initialized in sumOfSquaredWeights() or normalize()
53      * because they both are invoked either in Query::_initWeight (for top-level query) or
54      * in corresponding methods of parent query's weights
55      *
56      * @var float
57      */
58     protected $_value;
59
60
61     /**
62      * The weight for this query.
63      *
64      * @return float
65      */
66     public function getValue()
67     {
68         return $this->_value;
69     }
70
71     /**
72      * The sum of squared weights of contained query clauses.
73      *
74      * @return float
75      */
76     abstract public function sumOfSquaredWeights();
77
78     /**
79      * Assigns the query normalization factor to this.
80      *
81      * @param $norm
82      */
83     abstract public function normalize($norm);
84 }
85