NAME
CGI::Wiki::Search::SII - Search::InvertedIndex plugin for CGI::Wiki
SYNOPSIS
my $indexdb = Search::InvertedIndex::DB::Mysql->new( ... );
my $search = CGI::Wiki::Search::SII->new( indexdb => $indexdb );
my %wombat_nodes = $search->search_nodes("wombat");
Provides search-related methods for CGI::Wiki
METHODS
- new
-
# EITHER my $indexdb = Search::InvertedIndex::DB::Mysql->new( -db_name => $dbname, -username => $dbuser, -password => $dbpass, -hostname => '', -table_name => 'siindex', -lock_mode => 'EX' ); # OR my $indexdb = Search::InvertedIndex::DB::DB_File_SplitHash->new( -map_name => "/home/wiki/indexes.db", -lock_mode => "EX" ); # THEN my $search = CGI::Wiki::Search::SII->new( indexdb => $indexdb );
Takes only one parameter, which is mandatory.
indexdb
must be aSearch::InvertedIndex::DB::*
object. - 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
OR
oror
).Searches are case-insensitive.
- fuzzy_title_match
-
$wiki->write_node( "King's Cross St Pancras", "A station." ); my %matches = $search->fuzzy_title_match( "Kings Cross St. Pancras" );
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.
Note that even if an exact match is found, any other similar enough matches will also be returned. However, any exact match is guaranteed to have the highest relevance score.
The matching is done against "canonicalised" forms of the search string and the node titles in the database: stripping vowels, repeated letters and non-word characters, and lowercasing.
- index_node
-
$search->index_node($node, $content);
Indexes or reindexes the given node in the Search::InvertedIndex indexes. You must supply both the node name and its content.
- delete_node
-
$search->delete_node($node);
Removes the given node from the search indexes. NOTE: It's up to you to make sure the node is removed from the backend store. Croaks on error.
- supports_phrase_searches
-
if ( $search->supports_phrase_searches ) { return $search->search_nodes( '"fox in socks"' ); }
Returns true if this search backend supports phrase searching, and false otherwise.