1Wiki::Toolkit::Search::ULsuecry(C3o)ntributed Perl DocumWeinktia:t:iToonolkit::Search::Lucy(3)
2
3
4

NAME

6       Wiki::Toolkit::Search::Lucy - Use Lucy to search your Wiki::Toolkit
7       wiki.
8

SYNOPSIS

10         my $search = Wiki::Toolkit::Search::Lucy->new( path => "/var/lucy/wiki" );
11         my %wombat_nodes = $search->search_nodes( "wombat" );
12
13       Provides Lucy-based search methods for Wiki::Toolkit.
14

METHODS

16       new
17             my $search = Wiki::Toolkit::Search::Lucy->new(
18                 path => "/var/lucy/wiki",
19                 metadata_fields => [ "category", "locale", "address" ],
20                 boost => { title => 2.5 },
21                 content_munger => sub {
22                                       my $content = shift;
23                                       $content =~ s/secretword//gs;
24                                       return $content;
25                                   },
26                 node_filter => sub {
27                                    my %args = @_;
28                                    return $args{content} =~ /REDIRECT/ ? 0 : 1;
29                                   },
30             );
31
32           The "path" parameter is mandatory. "path" must be a directory for
33           storing the indexed data.  It should exist and be writeable.
34
35           The other four parameters are optional:
36
37           "metadata_fields" should be a reference to an array of metadata
38           field names.
39
40           "boost" should be a reference to a hash in which the keys are
41           fields and the values are numbers - see Lucy::Plan::FieldType for
42           more info.  Only "title" is currently supported as a field value.
43
44           "content_munger" should be a reference to a subroutine which takes
45           the node content as a string and returns another string which will
46           be indexed in place of the original content.
47
48           "node_filter" should be a reference to a subroutine which takes the
49           named arguments "node", "content", and "metadata" and returns
50           either true (yes, index this node) or false (no, don't index this
51           node).
52
53           Content munging takes place BEFORE node filtering.
54
55       index_node
56             $search->index_node( $node, $content, $metadata );
57
58           Indexes or reindexes the given node in the search engine indexes.
59           You must supply both the node name and its content, but metadata is
60           optional.
61
62           If you do supply metadata, it should be a reference to a hash where
63           the keys are the names of the metadata fields and the values are
64           either scalars or references to arrays of scalars.  For example:
65
66             $search->index_node( "Calthorpe Arms", "Nice pub in Bloomsbury.",
67                                  { category => [ "Pubs", "Bloomsbury" ],
68                                    postcode => "WC1X 8JR" } );
69
70           Only those metadata fields which were supplied to ->new will be
71           taken notice of - others will be silently ignored.
72
73           If "content_munger" has been supplied to "new" as a subroutine
74           reference, then $content will be run through this before indexing.
75
76           If "node_filter" has been supplied to "new" as a subroutine
77           reference, then this will be used to check whether the node should
78           be indexed or ignored.
79
80           Content munging takes place BEFORE node filtering.
81
82       search_nodes
83             # Find all the nodes which contain the word 'expert'.
84             my %results = $search->search_nodes( "expert" );
85
86           Returns a (possibly empty) hash whose keys are the node names and
87           whose values are the scores.
88
89           Defaults to AND searches (if $and_or is not supplied, or is
90           anything other than "OR" or "or").
91
92           Searches are case-insensitive.
93

SEE ALSO

95       Wiki::Toolkit, Wiki::Toolkit::Search::Base.
96
97
98
99perl v5.36.0                      2023-01-20    Wiki::Toolkit::Search::Lucy(3)
Impressum