Skip to content

Commit

Permalink
Add missing seek to RequiredOptionalScorer (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yomo authored Aug 19, 2022
1 parent e25ab5d commit 0c634c5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/query/reqopt_scorer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ where
self.req_scorer.advance()
}

fn seek(&mut self, target: DocId) -> DocId {
self.score_cache = None;
self.req_scorer.seek(target)
}

fn doc(&self) -> DocId {
self.req_scorer.doc()
}
Expand Down Expand Up @@ -172,4 +177,23 @@ mod tests {
skip_docs,
);
}

#[test]
fn test_reqopt_scorer_seek() {
let mut reqoptscorer: RequiredOptionalScorer<_, _, SumCombiner> =
RequiredOptionalScorer::new(
ConstScorer::new(VecDocSet::from(vec![1, 3, 7, 8, 9, 10, 13, 15]), 1.0),
ConstScorer::new(VecDocSet::from(vec![2, 7, 11, 12, 15]), 1.0),
);
{
assert_eq!(reqoptscorer.score(), 1.0);
assert_eq!(reqoptscorer.seek(7), 7);
assert_eq!(reqoptscorer.score(), 2.0);
}
{
assert_eq!(reqoptscorer.score(), 2.0);
assert_eq!(reqoptscorer.seek(12), 13);
assert_eq!(reqoptscorer.score(), 1.0);
}
}
}

0 comments on commit 0c634c5

Please sign in to comment.