25 |
|
|
26 |
=head1 VERSION |
=head1 VERSION |
27 |
|
|
28 |
Version 0.04 |
Version 0.05 |
29 |
|
|
30 |
=cut |
=cut |
31 |
|
|
32 |
our $VERSION = '0.04'; |
our $VERSION = '0.05'; |
33 |
|
|
34 |
=head1 SYNOPSIS |
=head1 SYNOPSIS |
35 |
|
|
42 |
|
|
43 |
Open KinoSearch index |
Open KinoSearch index |
44 |
|
|
45 |
my $est = new WebPAC::Output::KinoSearch({ |
my $out = new WebPAC::Output::KinoSearch({ |
46 |
path => '/path/to/invindex', |
path => '/path/to/invindex', |
47 |
database => 'demo', |
database => 'demo', |
48 |
encoding => 'iso-8859-2', |
encoding => 'iso-8859-2', |
69 |
|
|
70 |
=back |
=back |
71 |
|
|
72 |
|
=head2 init |
73 |
|
|
74 |
|
$out->init; |
75 |
|
|
76 |
=cut |
=cut |
77 |
|
|
78 |
sub init { |
sub init { |
93 |
if ( ! -e $self->path ) { |
if ( ! -e $self->path ) { |
94 |
mkpath $self->path || $log->logdie("can't create ", $self->path,": $!"); |
mkpath $self->path || $log->logdie("can't create ", $self->path,": $!"); |
95 |
$log->info("created ", $self->path); |
$log->info("created ", $self->path); |
96 |
|
} elsif ( $self->clean ) { |
97 |
|
$log->info("removing existing ", $self->path); |
98 |
|
rmtree $self->path || $log->logdie("can't remove ", $self->path,": $!"); |
99 |
|
mkpath $self->path || $log->logdie("can't create ", $self->path,": $!"); |
100 |
} |
} |
101 |
|
|
102 |
my $path = $self->path . '/' . $self->database; |
my $path = $self->path . '/' . $self->database; |
119 |
|
|
120 |
Adds one entry |
Adds one entry |
121 |
|
|
122 |
$est->add( 42, $ds ); |
$out->add( 42, $ds ); |
123 |
|
|
124 |
=cut |
=cut |
125 |
|
|
136 |
|
|
137 |
my $hash = $self->ds_to_hash( $ds, 'search' ) || return; |
my $hash = $self->ds_to_hash( $ds, 'search' ) || return; |
138 |
|
|
139 |
warn "add( $id, ",dump($ds)," ) => ", dump( $hash ); |
$hash->{database} ||= $self->database; |
140 |
|
$hash->{id} ||= $id; |
141 |
|
|
142 |
|
foreach my $f ( keys %$hash ) { |
143 |
|
if ( ref($hash->{$f}) eq 'ARRAY' ) { |
144 |
|
$hash->{$f} = join(' <*> ', @{ $hash->{$f} }); |
145 |
|
} |
146 |
|
} |
147 |
|
|
148 |
|
$log->debug("add( $id, ", sub { dump($ds) }," ) => ", sub { dump( $hash ) }); |
149 |
|
|
150 |
$self->index->add_doc( $hash ); |
$self->index->add_doc( $hash ); |
151 |
|
|
152 |
|
$self->{count}++; |
153 |
|
|
154 |
return 1; |
return 1; |
155 |
} |
} |
156 |
|
|
158 |
|
|
159 |
Close index |
Close index |
160 |
|
|
161 |
$index->finish; |
$out->finish; |
162 |
|
|
163 |
=cut |
=cut |
164 |
|
|
167 |
|
|
168 |
my $log = $self->_get_logger(); |
my $log = $self->_get_logger(); |
169 |
|
|
170 |
$log->info("dummy finish"); |
$log->info("indexed ", $self->{count}, " records"); |
|
|
|
|
} |
|
|
|
|
|
=head2 convert |
|
|
|
|
|
my $utf8_string = $self->convert('string in codepage'); |
|
|
|
|
|
=cut |
|
|
|
|
|
sub convert { |
|
|
my $self = shift; |
|
171 |
|
|
|
my $text = shift || return; |
|
|
from_to($text, $self->{encoding}, 'UTF-8'); |
|
|
return $text; |
|
172 |
} |
} |
173 |
|
|
174 |
=head1 AUTHOR |
=head1 AUTHOR |