NAME
SWISH::Prog::Index - handle Swish-e indexing
SYNOPSIS
use SWISH::Prog::Index
my $indexer = SWISH::Prog::Index->new(
format => 'native2' || 'btree2' || 'swish3',
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
DESCRIPTION
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. See SWISH3 for details about how version 3 will work.
FUNCTIONS
go
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!
Plus, Swish3 will have a native Perl XS API, and this module will support all versions with go(). See ENVIRONMENT VARIABLES for more details.
go() is the only export of this module.
METHODS
new
Create indexer object.
[TODO parameters]
fh
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.
rm
Remove the index (all the associated index files). Useful if creating a temp index for merging, etc.
files
Returns a list of all the associated files for the index.
run
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.
SWISH3
If the SWISH3
environment variable is set, SWISH::Prog::Index will load SWISH::Prog::Index::3 and use that interface instead.
AUTHOR
Peter Karman, <perl@peknet.com>
COPYRIGHT AND LICENSE
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.