web search done right
guard against terminated doc ids
Mikkel Denker866be554ed46
diff --git a/crates/core/src/collector/top_docs.rs b/crates/core/src/collector/top_docs.rsindex eedfb903..e92dc896 100644--- a/crates/core/src/collector/top_docs.rs+++ b/crates/core/src/collector/top_docs.rs@@ -151,7 +151,7 @@ impl TopSegmentCollector {}fn collect(&mut self, doc: DocId, score: Score) {- if self.is_done() {+ if self.is_done() || doc == tantivy::TERMINATED {return;}diff --git a/crates/core/src/webgraph/query/collector/top_docs.rs b/crates/core/src/webgraph/query/collector/top_docs.rsindex 16789523..dda3d705 100644--- a/crates/core/src/webgraph/query/collector/top_docs.rs+++ b/crates/core/src/webgraph/query/collector/top_docs.rs@@ -215,6 +215,10 @@ impl<S: DocumentScorer + 'static> SegmentCollector for TopDocsSegmentCollector<Stype Fruit = Vec<(tantivy::Score, DocAddress)>;fn collect(&mut self, doc: DocId, _: tantivy::Score) {+ if doc == tantivy::TERMINATED {+ return;+ }+let score = self.scorer.score(doc);self.computer.push(score, DocAddress::new(self.shard_id, self.segment_ord, doc));diff --git a/crates/core/src/webgraph/query/document_scorer/mod.rs b/crates/core/src/webgraph/query/document_scorer/mod.rsindex 661093e3..842300ff 100644--- a/crates/core/src/webgraph/query/document_scorer/mod.rs+++ b/crates/core/src/webgraph/query/document_scorer/mod.rs@@ -34,6 +34,10 @@ impl DocumentScorer for DefaultDocumentScorer {}fn score(&self, doc: DocId) -> Score {+ if doc == tantivy::TERMINATED {+ return 0.0;+ }+self.column.first(doc).unwrap_or(0.0) as Score}}