Email::Store::Plucene - Search your Email::Store with Plucene
use Email::Store; $Email::Store::Plucene::index_path = "/var/db/mailstore_index"; Email::Store::Mail->store($_) for @mails; Email::Store::Plucene->optimize; @some_mails = Email::Store::Mail->plucene_search("from:dan list:perl6-internals"); @may_mails = Email::Store::Mail->plucene_search_during ("from:dan list:perl6-internals", "2004-05-01", "2004-05-31");
This module adds Plucene indexing to Email::Store's indexing. Whenever a mail is indexed, an entry will be added in the Plucene index which is located at $Email::Store::Plucene::index_path. If you don't change this variable, you'll end up with an index called emailstore-index in the current directory.
$Email::Store::Plucene::index_path
The module hooks into the store method in the usual way, and provides two new search methods:
store
plucene_search
This takes a query and returns a list of mails matching that query. The query terms are by default joined together with the OR operator.
OR
plucene_search_during
As above, but also takes two ISO format dates, returning only mails in that period.
This module provides a hook called on_gather_plucene_fields. You should provide methods called on_gather_plucene_fields_order (a numeric ordering) and on_gather_plucene_fields. This last should expect a Email::Store::Mail object and a hash reference. Write into this hash reference any fields you want to be searchable:
on_gather_plucene_fields
on_gather_plucene_fields_order
Email::Store::Mail
package Email::Store::Annotations; sub on_gather_plucene_fields_order { 10 } sub on_gather_plucene_fields { my ($self, $mail, $hash); $hash->{notes} = join " ", $mail->annotations; }
Now you should be able to use notes:foo to search for mails with "foo" in their annotations.
notes:foo
Copyright 2004 by Simon Cozens
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Email::Store::Plucene, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Email::Store::Plucene
CPAN shell
perl -MCPAN -e shell install Email::Store::Plucene
For more information on module installation, please visit the detailed CPAN module installation guide.