Skip to content

Commit

Permalink
prevent undefined array key exception in _conjunctionScore
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Sep 25, 2023
1 parent 68c0249 commit 87370c0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions library/ZendSearch/Lucene/Search/Query/MultiTerm.php
Original file line number Diff line number Diff line change
Expand Up @@ -453,13 +453,16 @@ public function _conjunctionScore($docId, Lucene\SearchIndexInterface $reader)
$score = 0.0;

foreach ($this->_terms as $termId => $term) {
/**
* We don't need to check that term freq is not 0
* Score calculation is performed only for matched docs
*/
$score += $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) *
$this->_weights[$termId]->getValue() *
$reader->norm($docId, $term->field);
// Check if term is matched
if (isset($this->_termsFreqs[$termId][$docId])) {
/**
* We don't need to check that term freq is not 0
* Score calculation is performed only for matched docs
*/
$score += $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) *
$this->_weights[$termId]->getValue() *
$reader->norm($docId, $term->field);
}
}

return $score * $this->_coord * $this->getBoost();
Expand Down

0 comments on commit 87370c0

Please sign in to comment.