CGI-Wiki
view release on metacpan or search on metacpan
lib/CGI/Wiki/Search/Base.pm view on Meta::CPAN
package CGI::Wiki::Search::Base;
use strict;
use Carp "croak";
use vars qw( @ISA $VERSION );
sub _abstract {
my $who = (caller(1))[3];
croak "$who is an abstract method which the ".(ref shift).
" class has not provided";
}
$VERSION = 0.01;
=head1 NAME
CGI::Wiki::Search::Base - Base class for CGI::Wiki search plugins.
=head1 SYNOPSIS
my $search = CGI::Wiki::Search::XXX->new( @args );
my %wombat_nodes = $search->search_nodes("wombat");
This class details the methods that need to be overriden by search plugins.
=cut
=head1 METHODS
=over 4
=item B<new>
my $search = CGI::Wiki::Search::XXX->new( @args );
Creates a new searcher. By default the arguments are just passed to
C<_init>, so you may wish to override that instead.
=cut
sub new {
my ($class, @args) = @_;
my $self = {};
bless $self, $class;
return $self->_init(@args);
}
sub _init {
my ($self, %args) = @_;
@{$self}{keys %args} = values %args;
return $self;
}
=item B<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 in some kind of relevance-scoring system I
haven't entirely come up with yet. For OR searches, this could
initially be the number of terms that appear in the node, perhaps.
Defaults to AND searches (if $and_or is not supplied, or is anything
other than C<OR> or C<or>).
Searches are case-insensitive.
( run in 1.213 second using v1.01-cache-2.11-cpan-b16cb0d3907 )