logo
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<()> { ... } }
Expand description

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

See Query.

Required Methods

Returns the scorer for the given segment.

boost is a multiplier to apply to the score.

See Query.

Returns an Explanation for the given document.

Provided Methods

Returns the number documents within the given SegmentReader.

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

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).

Implementors