NAME

KinoSearch::Index::IndexReader - Read from an inverted index.

SYNOPSIS

    my $reader = KinoSearch::Index::IndexReader->open(
        invindex => MySchema->read('/path/to/invindex'),
    );

DESCRIPTION

IndexReader is the interface through which Searchers access the content of an InvIndex.

IndexReader objects always represent a point-in-time view of an invindex as it existed at the moment the reader was created. If you want search results to reflect modifications to an InvIndex, you must create a new IndexReader after the update process completes.

When a IndexReader is created, a small portion of the InvIndex is loaded into memory; additional sort caches are filled as relevant queries arrive. For large document collections, the warmup time may become noticable, in which case reusing the reader is likely to speed up your search application.

Caching an IndexReader (or a Searcher which contains an IndexReader) is especially helpful when running a high-activity app in a persistent environment, as under mod_perl or FastCGI.

CONSTRUCTOR

open( [labeled params] )

    my $reader = KinoSearch::Index::IndexReader->open(
        invindex     => MySchema->read('/path/to/invindex'),
        lock_factory => $lock_factory,
    );

IndexReader is an abstract base class; open() functions like a constructor, but actually returns one of two possible subclasses: SegReader, which reads a single segment, and MultiReader, which channels the output of several SegReaders. Since each segment is a self-contained inverted index, a SegReader is in effect a complete index reader.

METHODS

lexicon( [labeled params] )

Returns a Lexicon.

Returns undef if either the field is undef or the field can't be found in the index.

  • field - A field name.
  • term - If supplied, the Lexicon will be pre-located using seek().

posting_list( [labeled params] )

Returns a PostingList.

Returns undef if either the field is undef or the field can't be found in the index.

  • field - A field name.
  • term - If supplied, the PostingList will be pre-located using seek().

max_docs()

Return the maximum number of documents available to the reader, which is also the largest possible document number. Documents which have been marked as deleted but not yet purged from the index are included in this count.

num_docs()

Return the number documents available to the reader, subtracting any that are marked as deleted.

fetch_doc(doc_num)

Retrieve the stored fields for the given doc num, packaged as a HitDoc object. Throws an error if the doc num is out of range.

INHERITANCE

KinoSearch::Index::IndexReader isa KinoSearch::Obj.

COPYRIGHT

Copyright 2005-2008 Marvin Humphrey

LICENSE, DISCLAIMER, BUGS, etc.

See KinoSearch version 0.20.

Copyright © 2004-2008 Marvin Humphrey