1 package WebPAC::Output::KinoSearch;
6 use base qw/WebPAC::Common WebPAC::Output Class::Accessor/;
7 __PACKAGE__->mk_accessors(qw(
16 use KinoSearch::Simple;
18 use Encode qw/from_to/;
19 use Data::Dump qw/dump/;
24 WebPAC::Output::KinoSearch - Create KinoSearch full text index
32 our $VERSION = '0.04';
36 Create full text index using KinoSearch index from data with
45 my $est = new WebPAC::Output::KinoSearch({
46 path => '/path/to/invindex',
48 encoding => 'iso-8859-2',
58 path to KinoSearch index to use
62 name of database from which data comes
66 character encoding of C<data_structure> if it's differenet than C<ISO-8859-2>
67 (and it probably is). This encoding will be converted to C<UTF-8> for
77 my $log = $self->_get_logger;
79 #$log->debug("self: ", sub { dump($self) });
81 foreach my $p (qw/path database/) {
82 $log->logdie("need $p") unless ($self->$p);
85 # $log->logdie("fields is not ARRAY") unless (ref($self->{fields}) eq 'ARRAY');
87 $self->encoding( 'ISO-8859-2' ) unless $self->encoding;
89 if ( ! -e $self->path ) {
90 mkpath $self->path || $log->logdie("can't create ", $self->path,": $!");
91 $log->info("created ", $self->path);
94 my $path = $self->path . '/' . $self->database;
96 $log->info("using index $path with encoding ", $self->encoding);
98 my $index = KinoSearch::Simple->new(
103 $log->logdie("can't open $path: $!") unless $index;
105 $self->index( $index );
114 $est->add( 42, $ds );
121 my ( $id, $ds ) = @_;
123 my $log = $self->_get_logger;
124 $log->logdie("need id") unless defined $id;
125 $log->logdie("need ds") unless $ds;
127 $log->debug("id: $id ds = ",dump($ds));
129 my $hash = $self->ds_to_hash( $ds, 'search' ) || return;
131 warn "add( $id, ",dump($ds)," ) => ", dump( $hash );
133 $self->index->add_doc( $hash );
149 my $log = $self->_get_logger();
151 $log->info("dummy finish");
157 my $utf8_string = $self->convert('string in codepage');
164 my $text = shift || return;
165 from_to($text, $self->{encoding}, 'UTF-8');
171 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
173 =head1 COPYRIGHT & LICENSE
175 Copyright 2005-2007 Dobrica Pavlinusic, All Rights Reserved.
177 This program is free software; you can redistribute it and/or modify it
178 under the same terms as Perl itself.
182 1; # End of WebPAC::Output::Estraier