Plucene::Index::Writer - write an index.
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;
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.
optimize
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.
my $doc_count = $writer->doc_count;
$writer->add_document($doc);
$writer->optimize;
Merges all segments together into a single segment, optimizing an index for search.
$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.
To install Plucene, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plucene
CPAN shell
perl -MCPAN -e shell install Plucene
For more information on module installation, please visit the detailed CPAN module installation guide.