mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-06 01:02:55 +00:00
19 lines
542 B
Rust
19 lines
542 B
Rust
use super::Scorer;
|
|
use core::SegmentReader;
|
|
use Result;
|
|
|
|
/// A Weight is the specialization of a Query
|
|
/// for a given set of segments.
|
|
///
|
|
/// See [`Query`](./trait.Query.html).
|
|
pub trait Weight {
|
|
/// Returns the scorer for the given segment.
|
|
/// See [`Query`](./trait.Query.html).
|
|
fn scorer(&self, reader: &SegmentReader) -> Result<Box<Scorer>>;
|
|
|
|
/// Returns the number documents within the given `SegmentReader`.
|
|
fn count(&self, reader: &SegmentReader) -> Result<u32> {
|
|
Ok(self.scorer(reader)?.count())
|
|
}
|
|
}
|