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

pub trait Collector: Sync + Send {
    type Fruit: Fruit;
    type Child: SegmentCollector;
    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::Child as SegmentCollector>::Fruit>
    ) -> Result<Self::Fruit>; fn collect_segment(
        &self,
        weight: &dyn Weight,
        segment_ord: u32,
        reader: &SegmentReader
    ) -> Result<<Self::Child as SegmentCollector>::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[src]

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

type Child: SegmentCollector[src]

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>
[src]

set_segment is called before beginning to enumerate on this segment.

fn requires_scoring(&self) -> bool[src]

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

fn merge_fruits(
    &self,
    segment_fruits: Vec<<Self::Child as SegmentCollector>::Fruit>
) -> Result<Self::Fruit>
[src]

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

Loading content...

Provided methods

fn collect_segment(
    &self,
    weight: &dyn Weight,
    segment_ord: u32,
    reader: &SegmentReader
) -> Result<<Self::Child as SegmentCollector>::Fruit>
[src]

Created a segment collector and

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 DocSetCollector[src]

type Fruit = HashSet<DocAddress>

type Child = DocSetChildCollector

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

impl<TCollector, TPredicate, TPredicateValue: FastValue> Collector for FilterCollector<TCollector, TPredicate, TPredicateValue> where
    TCollector: Collector + Send + Sync,
    TPredicate: 'static + Fn(TPredicateValue) -> bool + Send + Sync,
    TPredicateValue: 'static + FastValue
[src]

type Fruit = TCollector::Fruit

type Child = FilterSegmentCollector<TCollector::Child, TPredicate, TPredicateValue>

Loading content...