diff --git a/src/postings/docset.rs b/src/postings/docset.rs index 24ae1ffe6..9dda32559 100644 --- a/src/postings/docset.rs +++ b/src/postings/docset.rs @@ -36,7 +36,9 @@ pub trait DocSet { /// skipping will advance to the next position and return SkipResult::Overstep. /// fn skip_next(&mut self, target: DocId) -> SkipResult { - self.advance(); + if !self.advance() { + return SkipResult::End; + } loop { match self.doc().cmp(&target) { Ordering::Less => { diff --git a/src/postings/intersection.rs b/src/postings/intersection.rs index 75699065c..d6fc20545 100644 --- a/src/postings/intersection.rs +++ b/src/postings/intersection.rs @@ -38,16 +38,9 @@ impl DocSet for IntersectionDocSet { return false; } let num_docsets = self.docsets.len(); - let mut count_matching = 1; - let mut doc_candidate = { - let mut first_docset = &mut self.docsets[0]; - if !first_docset.advance() { - self.finished = true; - return false; - } - first_docset.doc() - }; - let mut ord = 1; + let mut count_matching = 0; + let mut doc_candidate = 0; + let mut ord = 0; loop { let mut doc_set = &mut self.docsets[ord]; match doc_set.skip_next(doc_candidate) { diff --git a/src/postings/mod.rs b/src/postings/mod.rs index d6dcaf444..50df71eed 100644 --- a/src/postings/mod.rs +++ b/src/postings/mod.rs @@ -231,7 +231,7 @@ mod tests { let index = Index::create_in_ram(schema); { let mut index_writer = index.writer_with_num_threads(1, 40_000_000).unwrap(); - for _ in 0 .. 15_000_000 { + for _ in 0 .. 1_500_000 { let mut doc = Document::default(); if rng.gen_weighted_bool(15) { doc.add_text(text_field, "a");