Peter Karman > SWISH-Prog-0.74 > SWISH::Prog::Native::Indexer

Download:
SWISH-Prog-0.74.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.74   Source   Latest Release: SWISH-Prog-0.75

NAME ^

SWISH::Prog::Native::Indexer - wrapper around Swish-e binary

SYNOPSIS ^

 use SWISH::Prog::Native::Indexer;
 my $indexer = SWISH::Prog::Native::Indexer->new(
        invindex    => SWISH::Prog::Native::InvIndex->new,
        config      => SWISH::Prog::Config->new,
        count       => 0,
        clobber     => 1,
        flush       => 10000,
        started     => time(),
 );
 $indexer->start;
 for my $doc (@list_of_docs) {
    $indexer->process($doc);
 }
 $indexer->finish;

DESCRIPTION ^

The Native Indexer is a wrapper around the swish-e version 2.x binary tool.

METHODS ^

new

Create indexer object. All the following parameters are also accessor methods.

index

A SWISH::Prog::InvIndex::Native object.

config

A SWISH::Prog::Config object.

exe

The path to the swish-e executable. If empty, will just look in $ENV{PATH}.

verbose

Takes same args as swish-e -v option.

warnings

Takes same args as swish-e -W option.

opts

String of options passed directly to the swish-e program.

init

Initialize object. Called by new().

swish_check

Returns true if the exe() executable works, false otherwise.

start( [cmd] )

Start the indexer on its merry way. Stores the filehandle in fh().

Returns the $indexer object.

You likely don't want to pass cmd in but let start() construct it for you.

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 finish() method.

finish

Close the open fh() filehandle and check for any errors.

Called by the magic DESTROY method so $indexer will finish() whenever it goes out of scope.

merge( @InvIndex objects )

merge() will merge @SWISH::Prog::Native::InvIndex objects together with the index named in the calling Indexer object.

Returns the $indexer object on success, croaks on failure.

process( doc )

process() will parse and index doc. doc should be a SWISH::Prog::Doc instance.

Will croak() on failure.

add( doc )

Add doc to the index.

Note this is slower than merge(). If you have multiple doc objects, create a new Indexer object and process() them all, then merge() the two InvIndex objects.

 my $indexer = SWISH::Prog::Native::Indexer->new(invindex => 'tmpmerge');
 $indexer->start;
 for my $doc (@list_of_docs) {
     $indexer->process($doc);
 }
 $indexer->finish;
 $indexer->merge( 'path/to/other/index' );

AUTHOR ^

Peter Karman, <perl@peknet.com>

BUGS ^

Please report any bugs or feature requests to bug-swish-prog at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SWISH-Prog. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc SWISH::Prog

You can also look for information at:

COPYRIGHT AND LICENSE ^

Copyright 2008-2009 by Peter Karman

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

http://swish-e.org/

syntax highlighting: