Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

plucene::index::writer(3pm) [debian man page]

Plucene::Index::Writer(3pm)				User Contributed Perl Documentation			       Plucene::Index::Writer(3pm)

NAME
Plucene::Index::Writer - write an index. SYNOPSIS
my $writer = Plucene::Index::Writer->new($path, $analyser, $create); $writer->add_document($doc); $writer->add_indexes(@dirs); $writer->optimize; # called before close my $doc_count = $writer->doc_count; my $mergefactor = $writer->mergefactor; $writer->set_mergefactor($value); DESCRIPTION
This is the writer class. If an index will not have more documents added for a while and optimal search performance is desired, then the "optimize" method should be called before the index is closed. METHODS
new my $writer = Plucene::Index::Writer->new($path, $analyser, $create); This will create a new Plucene::Index::Writer object. The third argument to the constructor determines whether a new index is created, or whether an existing index is opened for the addition of new documents. mergefactor / set_mergefactor my $mergefactor = $writer->mergefactor; $writer->set_mergefactor($value); Get / set the mergefactor. It defaults to 5. doc_count my $doc_count = $writer->doc_count; add_document $writer->add_document($doc); Adds a document to the index. After the document has been added, a merge takes place if there are more than $Plucene::Index::Writer::mergefactor segments in the index. This defaults to 10, but can be set to whatever value is optimal for your application. optimize $writer->optimize; Merges all segments together into a single segment, optimizing an index for search. This should be the last method called on an indexer, as it invalidates the writer object. add_indexes $writer->add_indexes(@dirs); Merges all segments from an array of indexes into this index. This may be used to parallelize batch indexing. A large document collection can be broken into sub-collections. Each sub-collection can be indexed in parallel, on a different thread, process or machine. The complete index can then be created by merging sub-collection indexes with this method. After this completes, the index is optimized. perl v5.12.4 2011-08-14 Plucene::Index::Writer(3pm)

Check Out this Related Man Page

Plucene::TestCase(3pm)					User Contributed Perl Documentation				    Plucene::TestCase(3pm)

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
$DIR 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 $Plucene::TestCase::DEBUG is set to allow you to peruse the entrails. $WRITER A variable holding the current "Index::Writer" object, if there is one. $READER A variable holding the current "Index::Reader" object, if there is one. $ANALYZER A variable holding the class name of the desired "Analysis::Analyzer" class. new_index BLOCK (Analyzer) Create a new index, and do the following stuff in the block before closing the index writer. $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 $ANALYZER, which in turn defaults to "Plucene::Analysis::SimpleAnalyzer", will be used. re_index BLOCK (Analyzer) Same as "new_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 $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 "text". Returns a "Plucene::Search::Hits" object. The value of $ANALYZER will be used to construct an analyzer for the query string. perl v5.12.4 2011-08-14 Plucene::TestCase(3pm)
Man Page