root/wiki-toolkit/trunk/lib/Wiki/Toolkit/Setup/SII.pm

Revision 431, 2.2 KB (checked in by dom, 4 years ago)

fix much tab/whitespace damage; no functional changes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1package Wiki::Toolkit::Setup::SII;
2
3use strict;
4
5use vars qw( $VERSION );
6$VERSION = '0.03';
7
8use DBI;
9use Search::InvertedIndex;
10use Wiki::Toolkit::Search::SII;
11use Carp;
12
13=head1 NAME
14
15Wiki::Toolkit::Setup::SII - Set up Search::InvertedIndex indexes for Wiki::Toolkit
16
17=head1 SYNOPSIS
18
19  use Wiki::Toolkit::Setup::SII;
20  my $indexdb = Search::InvertedIndex::DB::Mysql->new(
21                   -db_name    => $dbname,
22                   -username   => $dbuser,
23                   -password   => $dbpass,
24           -hostname   => '',
25                   -table_name => 'siindex',
26                   -lock_mode  => 'EX' );
27  Wiki::Toolkit::Setup::SII::setup( indexdb => $indexdb );
28
29=head1 DESCRIPTION
30
31Set up L<Search::InvertedIndex> indexes for use with L<Wiki::Toolkit.> Has
32only one function, C<setup>, which takes one mandatory argument,
33C<indexdb>, the C<Search::InvertedIndex::DB::*> object to use as the
34backend, and one optional argument, C<store>, a C<Wiki::Toolkit::Store::*
35object> corresponding to existing data that you wish to (re-)index.
36
37Note that any pre-existing L<Wiki::Toolkit> indexes stored in C<indexdb>
38will be I<cleared> by this function, so if you have existing data you
39probably want to use the C<store> parameter to get it re-indexed.
40
41=cut
42
43sub setup {
44    my %args = @_;
45    my $indexdb = $args{indexdb};
46    croak "Must supply indexdb" unless $indexdb;
47
48    # Drop indexes if they already exist.
49    $indexdb->open;
50    $indexdb->clear;
51    $indexdb->close;
52
53    # If we've been passed a store, index all its data.
54    my $store = $args{store};
55    if ( $store ) {
56        my @nodes = $store->list_all_nodes;
57        my $search = Wiki::Toolkit::Search::SII->new( indexdb => $indexdb );
58        foreach my $node ( @nodes ) {
59            my $content = $store->retrieve_node( $node );
60            $search->index_node( $node, $content );
61        }
62    }
63}
64
65=head1 AUTHOR
66
67Kake Pugh (kake@earth.li).
68
69=head1 COPYRIGHT
70
71     Copyright (C) 2002 Kake Pugh.  All Rights Reserved.
72
73This module is free software; you can redistribute it and/or modify it
74under the same terms as Perl itself.
75
76=head1 SEE ALSO
77
78L<Wiki::Toolkit>, L<Wiki::Toolkit::Setup::MySQL>, L<DBIx::FullTextSearch>
79
80=cut
81
821;
Note: See TracBrowser for help on using the browser.