_query = $query; $this->_reader = $reader; } /** * The sum of squared weights of contained query clauses. * * @return float */ public function sumOfSquaredWeights() { // compute idf $this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader); // compute query weight $this->_queryWeight = $this->_idf * $this->_query->getBoost(); // square it return $this->_queryWeight * $this->_queryWeight; } /** * Assigns the query normalization factor to this. * * @param float $queryNorm */ public function normalize($queryNorm) { $this->_queryNorm = $queryNorm; // normalize query weight $this->_queryWeight *= $queryNorm; // idf for documents $this->_value = $this->_queryWeight * $this->_idf; } }