.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Wiki::Toolkit::Search::Lucy 3pm" .TH Wiki::Toolkit::Search::Lucy 3pm "2016-12-31" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Wiki::Toolkit::Search::Lucy \- Use Lucy to search your Wiki::Toolkit wiki. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& my $search = Wiki::Toolkit::Search::Lucy\->new( path => "/var/lucy/wiki" ); \& my %wombat_nodes = $search\->search_nodes( "wombat" ); .Ve .PP Provides Lucy\-based search methods for Wiki::Toolkit. .SH "METHODS" .IX Header "METHODS" .IP "\fBnew\fR" 4 .IX Item "new" .Vb 10 \& my $search = Wiki::Toolkit::Search::Lucy\->new( \& path => "/var/lucy/wiki", \& metadata_fields => [ "category", "locale", "address" ], \& boost => { title => 2.5 }, \& content_munger => sub { \& my $content = shift; \& $content =~ s/secretword//gs; \& return $content; \& }, \& node_filter => sub { \& my %args = @_; \& return $args{content} =~ /REDIRECT/ ? 0 : 1; \& }, \& ); .Ve .Sp The \f(CW\*(C`path\*(C'\fR parameter is mandatory. \f(CW\*(C`path\*(C'\fR must be a directory for storing the indexed data. It should exist and be writeable. .Sp The other four parameters are optional: .Sp \&\f(CW\*(C`metadata_fields\*(C'\fR should be a reference to an array of metadata field names. .Sp \&\f(CW\*(C`boost\*(C'\fR should be a reference to a hash in which the keys are fields and the values are numbers \- see Lucy::Plan::FieldType for more info. Only \f(CW\*(C`title\*(C'\fR is currently supported as a field value. .Sp \&\f(CW\*(C`content_munger\*(C'\fR should be a reference to a subroutine which takes the node content as a string and returns another string which will be indexed in place of the original content. .Sp \&\f(CW\*(C`node_filter\*(C'\fR should be a reference to a subroutine which takes the named arguments \f(CW\*(C`node\*(C'\fR, \f(CW\*(C`content\*(C'\fR, and \f(CW\*(C`metadata\*(C'\fR and returns either true (yes, index this node) or false (no, don't index this node). .Sp Content munging takes place \s-1BEFORE\s0 node filtering. .IP "\fBindex_node\fR" 4 .IX Item "index_node" .Vb 1 \& $search\->index_node( $node, $content, $metadata ); .Ve .Sp Indexes or reindexes the given node in the search engine indexes. You must supply both the node name and its content, but metadata is optional. .Sp If you do supply metadata, it should be a reference to a hash where the keys are the names of the metadata fields and the values are either scalars or references to arrays of scalars. For example: .Sp .Vb 3 \& $search\->index_node( "Calthorpe Arms", "Nice pub in Bloomsbury.", \& { category => [ "Pubs", "Bloomsbury" ], \& postcode => "WC1X 8JR" } ); .Ve .Sp Only those metadata fields which were supplied to \->new will be taken notice of \- others will be silently ignored. .Sp If \f(CW\*(C`content_munger\*(C'\fR has been supplied to \f(CW\*(C`new\*(C'\fR as a subroutine reference, then \f(CW$content\fR will be run through this before indexing. .Sp If \f(CW\*(C`node_filter\*(C'\fR has been supplied to \f(CW\*(C`new\*(C'\fR as a subroutine reference, then this will be used to check whether the node should be indexed or ignored. .Sp Content munging takes place \s-1BEFORE\s0 node filtering. .IP "\fBsearch_nodes\fR" 4 .IX Item "search_nodes" .Vb 2 \& # Find all the nodes which contain the word \*(Aqexpert\*(Aq. \& my %results = $search\->search_nodes( "expert" ); .Ve .Sp Returns a (possibly empty) hash whose keys are the node names and whose values are the scores. .Sp Defaults to \s-1AND\s0 searches (if \f(CW$and_or\fR is not supplied, or is anything other than \f(CW\*(C`OR\*(C'\fR or \f(CW\*(C`or\*(C'\fR). .Sp Searches are case-insensitive. .SH "SEE ALSO" .IX Header "SEE ALSO" Wiki::Toolkit, Wiki::Toolkit::Search::Base.