Skip to content

web search done right

Fixed bug that caused some queries to panic. Since we didn't check if the positions[i] vector had elements, some searches caused the weights and positions vector to have a different number of elements, thereby crashing on .zip_eq

Mikkel Denker7e31e98bb7c4
diff --git a/src/query/term_intersection.rs b/src/query/term_intersection.rs
index b312535c..2f2a90e5 100644
--- a/src/query/term_intersection.rs
+++ b/src/query/term_intersection.rs
@@ -137,7 +137,6 @@ impl Scorer for TermIntersection {
.map(|(field_id, terms)| {
let mut weights = Vec::new();
for (i, (term, weight)) in terms.into_iter().enumerate() {
- weights.push(weight);
if term.doc() == TERMINATED {
for pos in &mut positions[i..] {
if !pos.is_empty() {
@@ -146,7 +145,7 @@ impl Scorer for TermIntersection {
}
break;
}
-
+ weights.push(weight);
term.positions(positions.get_mut(i).unwrap());
}
@@ -159,6 +158,7 @@ impl Scorer for TermIntersection {
positions
.iter()
+ .filter(|pos| !pos.is_empty())
.zip_eq(weights.iter())
.enumerate()
.map(|(term_id, (_pos, weight))| {