[][src]Trait tantivy::collector::Collector

pub trait Collector: Sync {
    type Fruit: Fruit;
    type Child: SegmentCollector<Fruit = Self::Fruit>;
    fn for_segment(
        &self,
        segment_local_id: SegmentLocalId,
        segment: &SegmentReader
    ) -> Result<Self::Child>;
fn requires_scoring(&self) -> bool;
fn merge_fruits(
        &self,
        segment_fruits: Vec<Self::Fruit>
    ) -> Result<Self::Fruit>; }

Collectors are in charge of collecting and retaining relevant information from the document found and scored by the query.

For instance,

  • keeping track of the top 10 best documents
  • computing a breakdown over a fast field
  • computing the number of documents matching the query

Our search index is in fact a collection of segments, so a Collector trait is actually more of a factory to instance SegmentCollectors for each segments.

The collection logic itself is in the SegmentCollector.

Segments are not guaranteed to be visited in any specific order.

Associated Types

type Fruit: Fruit

Fruit is the type for the result of our collection. e.g. usize for the Count collector.

type Child: SegmentCollector<Fruit = Self::Fruit>

Type of the SegmentCollector associated to this collector.

Loading content...

Required methods

fn for_segment(
    &self,
    segment_local_id: SegmentLocalId,
    segment: &SegmentReader
) -> Result<Self::Child>

set_segment is called before beginning to enumerate on this segment.

fn requires_scoring(&self) -> bool

Returns true iff the collector requires to compute scores for documents.

fn merge_fruits(&self, segment_fruits: Vec<Self::Fruit>) -> Result<Self::Fruit>

Combines the fruit associated to the collection of each segments into one fruit.

Loading content...

Implementations on Foreign Types

impl<Left, Right> Collector for (Left, Right) where
    Left: Collector,
    Right: Collector
[src]

type Fruit = (Left::Fruit, Right::Fruit)

type Child = (Left::Child, Right::Child)

impl<One, Two, Three> Collector for (One, Two, Three) where
    One: Collector,
    Two: Collector,
    Three: Collector
[src]

type Fruit = (One::Fruit, Two::Fruit, Three::Fruit)

type Child = (One::Child, Two::Child, Three::Child)

impl<One, Two, Three, Four> Collector for (One, Two, Three, Four) where
    One: Collector,
    Two: Collector,
    Three: Collector,
    Four: Collector
[src]

type Fruit = (One::Fruit, Two::Fruit, Three::Fruit, Four::Fruit)

type Child = (One::Child, Two::Child, Three::Child, Four::Child)

Loading content...

Implementors

impl Collector for Count[src]

type Fruit = usize

type Child = SegmentCountCollector

impl Collector for FacetCollector[src]

type Fruit = FacetCounts

type Child = FacetSegmentCollector

impl Collector for TopDocs[src]

type Fruit = Vec<(Score, DocAddress)>

type Child = TopScoreSegmentCollector

impl<'a> Collector for MultiCollector<'a>[src]

type Fruit = MultiFruit

type Child = MultiCollectorChild

Loading content...