Trait tantivy::query::Weight[][src]

pub trait Weight: Send + Sync + 'static {
    fn scorer(
        &self,
        reader: &SegmentReader,
        boost: Score
    ) -> Result<Box<dyn Scorer>>;
fn explain(&self, reader: &SegmentReader, doc: DocId) -> Result<Explanation>; fn count(&self, reader: &SegmentReader) -> Result<u32> { ... }
fn for_each(
        &self,
        reader: &SegmentReader,
        callback: &mut dyn FnMut(DocId, Score)
    ) -> Result<()> { ... }
fn for_each_pruning(
        &self,
        threshold: Score,
        reader: &SegmentReader,
        callback: &mut dyn FnMut(DocId, Score) -> Score
    ) -> Result<()> { ... } }

A Weight is the specialization of a Query for a given set of segments.

See Query.

Required methods

fn scorer(
    &self,
    reader: &SegmentReader,
    boost: Score
) -> Result<Box<dyn Scorer>>
[src]

Returns the scorer for the given segment.

boost is a multiplier to apply to the score.

See Query.

fn explain(&self, reader: &SegmentReader, doc: DocId) -> Result<Explanation>[src]

Returns an Explanation for the given document.

Loading content...

Provided methods

fn count(&self, reader: &SegmentReader) -> Result<u32>[src]

Returns the number documents within the given SegmentReader.

fn for_each(
    &self,
    reader: &SegmentReader,
    callback: &mut dyn FnMut(DocId, Score)
) -> Result<()>
[src]

Iterates through all of the document matched by the DocSet DocSet and push the scored documents to the collector.

fn for_each_pruning(
    &self,
    threshold: Score,
    reader: &SegmentReader,
    callback: &mut dyn FnMut(DocId, Score) -> Score
) -> Result<()>
[src]

Calls callback with all of the (doc, score) for which score is exceeding a given threshold.

This method is useful for the TopDocs collector. For all docsets, the blanket implementation has the benefit of prefiltering (doc, score) pairs, avoiding the virtual dispatch cost.

More importantly, it makes it possible for scorers to implement important optimization (e.g. BlockWAND for union).

Loading content...

Implementors

impl Weight for AllWeight[src]

impl Weight for EmptyWeight[src]

impl<A> Weight for AutomatonWeight<A> where
    A: Automaton + Send + Sync + 'static,
    A::State: Clone
[src]

Loading content...