man Plucene::TestCase () - Handy functions when testing Plucene

NAME

Plucene::TestCase - Handy functions when testing Plucene

SYNOPSIS

        use Test::More tests => 10;
        use Plucene::TestCase;

        new_index {
                add_document( foo => "bar" );
        };

        re_index {
                add_document( foo => "baz" );
        }

        with_reader {
                $READER->whatever;
        }

        my $hits = search("foo:ba*");

EXPORTS

A directory which is created for the purposes of this test, in which the index will be placed. It will normally be cleaned up at the end of the test, unless CW$Plucene::TestCase::DEBUG is set to allow you to peruse the entrails. A variable holding the current CWIndex::Writer object, if there is one. A variable holding the current CWIndex::Reader object, if there is one. A variable holding the class name of the desired CWAnalysis::Analyzer class.

new_index BLOCK (Analyzer)
Create a new index, and do the following stuff in the block before closing the index writer. CW$WRITER is set for the duration of the block. The optional parameter should be the class name of the analyzer to use; if not specified, the value from CW$ANALYZER, which in turn defaults to CWPlucene::Analysis::SimpleAnalyzer, will be used.
re_index BLOCK (Analyzer)
Same as CWnew_index, but doesn't create a new index, rather re-uses an old one.
add_document( field1 => value1, ...)
Add a new document to the index, with the given fields and values
with_reader BLOCK
Opens an index reader in CW$READER and runs the block.
search
Searches for the query given. If any fields are not specified, they will be assumed to be the default CWtext. Returns a CWPlucene::Search::Hits object. The value of CW$ANALYZER will be used to construct an analyzer for the query string.