Apache-Wyrd
view release on metacpan or search on metacpan
Wyrd/Services/MySQLIndex.pm view on Meta::CPAN
package Apache::Wyrd::Services::MySQLIndex;
use base qw(Apache::Wyrd::Services::Index);
use 5.006;
use strict;
use warnings;
no warnings qw(uninitialized);
our $VERSION = '0.98';
use Apache::Wyrd::Services::SAK qw(token_parse strip_html);
use Apache::Wyrd::Services::SearchParser;
use Digest::SHA qw(sha1_hex);
use Data::Dumper;
=pod
=head1 NAME
Apache::Wyrd::Services::MySQLIndex - MySQL version of Index
=head1 SYNOPSIS
sub new {
my ($class) = @_;
my $dbh = DBI->connect('DBI:mysql:dbname', 'username', 'password');
my $init = {
dbh => $dbh,
debug => 0,
attributes => [qw(doctype section parent)],
maps => [qw(tags children)],
};
return &Apache::Wyrd::Site::MySQLIndex::new($class, $init);
}
my @subject_is_foobar = $index->word_search('foobar', 'subjects');
my @pages =
$index->word_search('+musthaveword -mustnothaveword
other words to search for and add to results');
foreach my $page (@pages) {
print "title: $$page{title}, author: $$page{author};
}
my @pages = $index->parsed_search('(this AND that) OR "the other"');
foreach my $page (@pages) {
print "title: $$page{title}, author: $$page{author};
}
=head1 DESCRIPTION
This is a MySQL-backed version of C<Apache::Wyrd::Services::Index>, and in most
ways behaves exactly the same way, using the same methods. Consequently, only
the differences are documented here.
=head1 METHODS
I<(format: (returns) name (arguments after self))>
=over
=item (Apache::Wyrd::Services::Index) C<new> (hashref)
Create a new MySQLIndex object. Unlike the BDB-backed version, MySQLIndex is not (yet) capable of auto-creating the database backend. In this backend, tables for each indexed object must be made as well as a separate table for every reverse index, ...
drop table if exists _wyrd_index;
create table _wyrd_index (
id integer not null auto_increment primary key,
name varchar(255) unique,
timestamp long,
digest char(40),
data blob,
wordcount integer,
( run in 0.830 second using v1.01-cache-2.11-cpan-39bf76dae61 )