SWISH::Prog::Index - handle Swish-e indexing
use SWISH::Prog::Index my $indexer = SWISH::Prog::Index->new( format => 'native2' || 'btree2', config => SWISH::Prog::Config->new, exe => 'path/to/swish-e', verbose => 0|1|2|3, warnings => 0|1|2|3, name => 'path/to/myindex' ); $indexer->run; print "index files: $_" for $indexer->files; # or from the command line DirTree.pl some/path | perl -MSWISH::Prog::Index -e go
SWISH::Prog::Index performs Swish-e indexing. For version 2.x of Swish-e this is simply a convenience wrapper around the swish-e binary executable.
Magic method to run the indexer with all defaults. See SYNOPSIS for an example.
You might object that the perl line is harder to remember than 'swish-e -v0 -W0 -S prog -i stdin' and it takes 0.1 second longer to run.
True enough. But go() was easy to code in two lines, so I did. And it requires one less keystroke. Laziness is a virtue!
go() is the only export of this module.
Create indexer object. All the following parameters are also accessor methods.
The name of the index. Should be a file path.
A SWISH::Prog::Config object.
The path to the swish-e executable. If empty, will just look in $ENV{PATH}.
swish-e
Takes same args as swish-e -v option.
swish-e -v
Takes same args as swish-e -W option.
swish-e -W
Tell the indexer what kind of index to expect. Options are native2 (default) or btree (for the experimental incremental feature in version 2.4).
native2
btree
The format param API is subject to change as Swish3 is developed.
format
Get or set the open() filehandle for the swish-e process. CAUTION: don't set unless you know what you're doing.
You can print() to the filehandle using the SWISH::Prog index() method. Or do it directly like:
print { $indexer->fh } "your headers and body here";
The filehandle is close()'d by the DESTROY magic method in this class. So when $indexer goes undef, the indexing process is closed automatically.
Remove the index (all the associated index files). Useful if creating a temp index for merging, etc.
Returns 0 and carps if there was a problem unlink()ing any file. Returns 1 otherwise.
Rename the index. Useful if creating temp indexes, etc.
Returns 1 on success, 0 on failure.
Returns a list of all the associated files for the index.
Start the indexer on its merry way. Stores the filehandle with the fh method for later access via SWISH::Prog or other methods TBD.
Returns the $indexer object.
You likely don't want to pass cmd in but let run() construct it for you.
merge() will merge @list_of_indexes together with the index named in the calling object.
Returns the $indexer object on success, 0 on failure.
add() will merge swish_prog_doc_object with the index named in the calling object. If the existing index uses the btree2 format (incremental mode), that API will be used. Otherwise, swish_prog_doc_object is indexed as a temporary index and then merged.
Returns $indexer object on success, 0 on failure.
Peter Karman, <perl@peknet.com>
Copyright 2006 by Peter Karman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SWISH::Prog, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SWISH::Prog
CPAN shell
perl -MCPAN -e shell install SWISH::Prog
For more information on module installation, please visit the detailed CPAN module installation guide.