CGI::Wiki::Search::SII - Search::InvertedIndex plugin for CGI::Wiki
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
# 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 a Search::InvertedIndex::DB::* object.
indexdb
Search::InvertedIndex::DB::*
# 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 or or).
OR
or
Searches are case-insensitive.
$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.
$search->index_node($node);
Indexes or reindexes the given node in the Search::InvertedIndex indexes.
$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.
if ( $search->supports_phrase_searches ) { return $search->search_nodes( '"fox in socks"' ); }
Returns true if this search backend supports phrase searching, and false otherwise.
CGI::Wiki
To install CGI::Wiki, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Wiki
CPAN shell
perl -MCPAN -e shell install CGI::Wiki
For more information on module installation, please visit the detailed CPAN module installation guide.