Struct tantivy::SegmentReader
[−]
[src]
pub struct SegmentReader { /* fields omitted */ }
Entry point to access all of the datastructures of the Segment
- term dictionary
- postings
- store
- fast field readers
- field norm reader
The segment reader has a very low memory footprint, as close to all of the memory data is mmapped.
Methods
impl SegmentReader
[src]
fn max_doc(&self) -> DocId
Returns the highest document id ever attributed in
this segment + 1.
Today, tantivy
does not handle deletes, so it happens
to also be the number of documents in the index.
fn num_docs(&self) -> DocId
Returns the number of documents. Deleted documents are not counted.
Today, tantivy
does not handle deletes so max doc and
num_docs are the same.
fn get_fast_field_reader(&self, field: Field) -> Result<U32FastFieldReader>
Accessor to a segment's fast field reader given a field.
fn get_fieldnorms_reader(&self, field: Field) -> Result<U32FastFieldReader>
Accessor to the segment's Field norms
's reader.
Field norms are the length (in tokens) of the fields. It is used in the computation of the TfIdf.
They are simply stored as a fast field, serialized in
the .fieldnorm
file of the segment.
fn doc_freq(&self, term: &Term) -> u32
Returns the number of documents containing the term.
fn get_store_reader(&self) -> &StoreReader
Accessor to the segment's StoreReader
.
fn open(segment: Segment) -> Result<SegmentReader>
Open a new segment for reading.
fn term_infos(&self) -> &FstMap<TermInfo>
Return the term dictionary datastructure.
fn doc(&self, doc_id: DocId) -> Result<Document>
Returns the document (or to be accurate, its stored field) bearing the given doc id. This method is slow and should seldom be called from within a collector.
fn read_postings(&self,
term: &Term,
option: SegmentPostingsOption)
-> Option<SegmentPostings>
term: &Term,
option: SegmentPostingsOption)
-> Option<SegmentPostings>
Returns the segment postings associated with the term, and with the given option,
or None
if the term has never been encounterred and indexed.
If the field was not indexed with the indexing options that cover
the requested options, the returned SegmentPostings
the method does not fail
and returns a SegmentPostings
with as much information as possible.
For instance, requesting SegmentPostingsOption::FreqAndPositions
for a TextIndexingOptions
that does not index position will return a SegmentPostings
with DocId
s and frequencies.
fn read_postings_all_info(&self, term: &Term) -> Option<SegmentPostings>
Returns the posting list associated with a term.
fn get_term_info(&self, term: &Term) -> Option<TermInfo>
Returns the term info associated with the term.