/// Returns a field reader associated to the field given in argument.
/// If the field was not present in the index during indexing time,
/// the InvertedIndexReader is empty.
///
/// The field reader is in charge of iterating through the
/// term dictionary associated to a specific field,
/// and opening the posting list associated to any term.
Returns a field reader associated to the field given in argument.
If the field was not present in the index during indexing time,
the InvertedIndexReader is empty.

The field reader is in charge of iterating through the
term dictionary associated to a specific field,
and opening the posting list associated to any term.
Returns a field reader associated to the field given in argument . If the field was not present in the index during indexing time the InvertedIndexReader is empty . The field reader is in charge of iterating through the term dictionary associated to a specific field and opening the posting list associated to any term .
pub fn inverted_index(&self, field: Field) -> Arc<InvertedIndexReader> {
        if let Some(inv_idx_reader) = self
            .inv_idx_reader_cache
            .read()
            .expect("Lock poisoned. This should never happen")
            .get(&field)
        {
            return Arc::clone(inv_idx_reader);
        }
        let field_entry = self.schema.get_field_entry(field);
        let field_type = field_entry.field_type();
        let record_option_opt = field_type.get_index_record_option();
        if record_option_opt.is_none() {
            panic!("Field {:?} does not seem indexed.", field_entry.name());
        }
        let record_option = record_option_opt.unwrap();
        let postings_source_opt = self.postings_composite.open_read(field);
        if postings_source_opt.is_none() {
            // no documents in the segment contained this field.
            // As a result, no data is associated to the inverted index.
            //
            // Returns an empty inverted index.
            return Arc::new(InvertedIndexReader::empty(field_type));
        }
        let postings_source = postings_source_opt.unwrap();
        let termdict_source = self.termdict_composite.open_read(field).expect(
            "Failed to open field term dictionary in composite file. Is the field indexed?",
        );
        let positions_source = self
            .positions_composite
            .open_read(field)
            .expect("Index corrupted. Failed to open field positions in composite file.");
        let positions_idx_source = self
            .positions_idx_composite
            .open_read(field)
            .expect("Index corrupted. Failed to open field positions in composite file.");
        let inv_idx_reader = Arc::new(InvertedIndexReader::new(
            TermDictionary::from_source(&termdict_source),
            postings_source,
            positions_source,
            positions_idx_source,
            record_option,
        ));
        // by releasing the lock in between, we may end up opening the inverting index
        // twice, but this is fine.
        self.inv_idx_reader_cache
            .write()
            .expect("Field reader cache lock poisoned. This should never happen.")
            .insert(field, Arc::clone(&inv_idx_reader));
        inv_idx_reader
    }
pub fn inverted_index ( & self , field : Field ) -> Arc < InvertedIndexReader > { if let Some ( inv_idx_reader ) = self . inv_idx_reader_cache . read ( ) . expect ( " " ) . get ( & field ) { return Arc :: clone ( inv_idx_reader ) ; } let field_entry = self . schema . get_field_entry ( field ) ; let field_type = field_entry . field_type ( ) ; let record_option_opt = field_type . get_index_record_option ( ) ; if record_option_opt . is_none ( ) { panic ! ( " " field_entry name ( ) ) ; } let record_option = record_option_opt . unwrap ( ) ; let postings_source_opt = self . postings_composite . open_read ( field ) ; if postings_source_opt . is_none ( ) { // no documents in the segment contained this field. // As a result, no data is associated to the inverted index. // // Returns an empty inverted index. return Arc :: new ( InvertedIndexReader :: empty ( field_type ) ) ; } let postings_source = postings_source_opt . unwrap ( ) ; let termdict_source = self . termdict_composite . open_read ( field ) . expect ( " " , ) ; let positions_source = self . positions_composite . open_read ( field ) . expect ( " " ) ; let positions_idx_source = self . positions_idx_composite . open_read ( field ) . expect ( " " ) ; let inv_idx_reader = Arc :: new ( InvertedIndexReader :: new ( TermDictionary :: from_source ( & termdict_source ) , postings_source , positions_source , positions_idx_source , record_option , ) ) ; // by releasing the lock in between, we may end up opening the inverting index // twice, but this is fine. self . inv_idx_reader_cache . write ( ) . expect ( " " ) . insert ( field , Arc :: clone ( & inv_idx_reader ) ) ; inv_idx_reader }
Returns a field reader associated to the field given in argument.
Returns a field reader associated to the field given in argument .
&self
field
Field