The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

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

SYNOPSIS

  my $search = Wiki::Toolkit::Search::Lucy->new( path => "/var/lucy/wiki" );
  my %wombat_nodes = $search->search_nodes( "wombat" );

Provides Lucy-based search methods for Wiki::Toolkit.

METHODS

new
  my $search = Wiki::Toolkit::Search::Lucy->new(
      path => "/var/lucy/wiki",
      metadata_fields => [ "category", "locale", "address" ],
      boost => { title => 2.5 } );

The path parameter is mandatory. path must be a directory for storing the indexed data. It should exist and be writeable.

The metadata_fields parameter is optional. It should be a reference to an array of metadata field names.

The boost parameter is also optional. It 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 title is currently supported as a field value.

index_node
  $search->index_node( $node, $content, $metadata );

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.

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:

  $search->index_node( "Calthorpe Arms", "Nice pub in Bloomsbury.",
                       { category => [ "Pubs", "Bloomsbury" ],
                         postcode => "WC1X 8JR" } );

Only those metadata fields which were supplied to ->new will be taken notice of - others will be silently ignored.

search_nodes
  # Find all the nodes which contain the word 'expert'.
  my %results = $search->search_nodes( "expert" );

Returns a (possibly empty) hash whose keys are the node names and whose values are the scores.

Defaults to AND searches (if $and_or is not supplied, or is anything other than OR or or).

Searches are case-insensitive.

SEE ALSO

Wiki::Toolkit, Wiki::Toolkit::Search::Base.