mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-08 10:02:55 +00:00
Added a count method
This commit is contained in:
@@ -2,6 +2,7 @@ use Term;
|
||||
use query::Weight;
|
||||
use core::SegmentReader;
|
||||
use query::Scorer;
|
||||
use DocSet;
|
||||
use postings::SegmentPostings;
|
||||
use schema::IndexRecordOption;
|
||||
use super::term_scorer::TermScorer;
|
||||
@@ -19,6 +20,14 @@ impl Weight for TermWeight {
|
||||
let specialized_scorer = self.specialized_scorer(reader)?;
|
||||
Ok(box specialized_scorer)
|
||||
}
|
||||
|
||||
fn count(&self, reader: &SegmentReader) -> Result<u32> {
|
||||
if reader.num_deleted_docs() == 0 {
|
||||
Ok(self.doc_freq)
|
||||
} else {
|
||||
Ok(self.specialized_scorer(reader)?.count())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TermWeight {
|
||||
|
||||
Reference in New Issue
Block a user