/** * Checks, that document is deleted * * @param integer * @return boolean */ public function isDeleted($id) { if ($this->_deleted === null) { return false; } if (extension_loaded('bitset')) { return bitset_in($this->_deleted, $id); } else { return isset($this->_deleted[$id]); } }
/** * Score specified document * * @param integer $docId * @param Zend_Search_Lucene $reader * @return float */ public function score($docId, $reader) { if ($this->_docVector === null) { if (extension_loaded('bitset')) { $this->_docVector = bitset_from_array($reader->termDocs($this->_term)); } else { $this->_docVector = array_flip($reader->termDocs($this->_term)); } $this->_termPositions = $reader->termPositions($this->_term); $this->_initWeight($reader); } $match = extension_loaded('bitset') ? bitset_in($this->_docVector, $docId) : isset($this->_docVector[$docId]); if ($this->_sign && $match) { return $reader->getSimilarity()->tf(count($this->_termPositions[$docId])) * $this->_weight->getValue() * $reader->norm($docId, $this->_term->field); } else { return 0; } }
/** * Score specified document * * @param integer $docId * @param ZSearch $reader * @return float */ public function score($docId, $reader) { // optimize zero-term case if (count($this->_terms) == 0) { return 0; } if ($this->_resVector === null) { $this->_calculateResult($reader); $this->_initWeight($reader); } if (extension_loaded('bitset') ? bitset_in($this->_resVector, $docId) : isset($this->_resVector[$docId])) { if ($this->_slop == 0) { $freq = $this->_exactPhraseFreq($docId); } else { $freq = $this->_sloppyPhraseFreq($docId, $reader); } /* return $reader->getSimilarity()->tf($freq) * $this->_weight->getValue() * $reader->norm($docId, reset($this->_terms)->field); */ if ($freq != 0) { $tf = $reader->getSimilarity()->tf($freq); $weight = $this->_weight->getValue(); $norm = $reader->norm($docId, reset($this->_terms)->field); return $tf * $weight * $norm; } } else { return 0; } }
/** * Score specified document * * @param integer $docId * @param Zend_Search_Lucene $reader * @return float */ public function score($docId, $reader) { if ($this->_resVector === null) { if ($this->_signs === null) { $this->_calculateConjunctionResult($reader); } else { $this->_calculateNonConjunctionResult($reader); } $this->_initWeight($reader); } if (extension_loaded('bitset') ? bitset_in($this->_resVector, $docId) : isset($this->_resVector[$docId])) { if ($this->_signs === null) { return $this->_conjunctionScore($docId, $reader); } else { return $this->_nonConjunctionScore($docId, $reader); } } else { return 0; } }