NAME
Email::Store::Plucene - Search your Email::Store with Plucene
SYNOPSIS
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"
);
DESCRIPTION
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.
METHODS
The module hooks into the store
method in the usual way, and provides two new search methods:
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. plucene_search_during
-
As above, but also takes two ISO format dates, returning only mails in that period.
NOTES FOR PLUG-IN WRITERS
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:
package
Email::Store::Annotations;
sub
on_gather_plucene_fields_order { 10 }
sub
on_gather_plucene_fields {
my
(
$self
,
,
$hash
);
$hash
->{notes} =
join
" "
,
->annotations;
}
Now you should be able to use notes:foo
to search for mails with "foo" in their annotations.
COPYRIGHT AND LICENSE
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.