Trait tantivy::collector::Collector
[−]
[src]
pub trait Collector { fn set_segment(
&mut self,
segment_local_id: SegmentLocalId,
segment: &SegmentReader
) -> Result<()>; fn collect(&mut self, doc: DocId, score: Score); }
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
Queries are in charge of pushing the DocSet
to the collector.
As they work on multiple segments, they first inform
the collector of a change in a segment and then
call the collect
method to push the document to the collector.
Temporally, our collector will receive calls
.set_segment(0, segment_reader_0)
.collect(doc0_of_segment_0)
.collect(...)
.collect(last_doc_of_segment_0)
.set_segment(1, segment_reader_1)
.collect(doc0_of_segment_1)
.collect(...)
.collect(last_doc_of_segment_1)
...
.collect(last_doc_of_last_segment)
Segments are not guaranteed to be visited in any specific order.
Required Methods
fn set_segment(
&mut self,
segment_local_id: SegmentLocalId,
segment: &SegmentReader
) -> Result<()>
&mut self,
segment_local_id: SegmentLocalId,
segment: &SegmentReader
) -> Result<()>
set_segment
is called before beginning to enumerate
on this segment.
fn collect(&mut self, doc: DocId, score: Score)
The query pushes the scored document to the collector via this method.
Implementations on Foreign Types
impl<'a, C: Collector> Collector for &'a mut C
[src]
fn set_segment(
&mut self,
segment_local_id: SegmentLocalId,
segment: &SegmentReader
) -> Result<()>
[src]
&mut self,
segment_local_id: SegmentLocalId,
segment: &SegmentReader
) -> Result<()>
fn collect(&mut self, doc: DocId, score: Score)
[src]
The query pushes the scored document to the collector via this method.
Implementors
impl Collector for CountCollector
impl<'a> Collector for MultiCollector<'a>
impl Collector for TopCollector
impl Collector for FacetCollector