154 |
$log->debug("creating $uri"); |
$log->debug("creating $uri"); |
155 |
|
|
156 |
my $doc = $self->{invindex}->new_doc( $uri ) || $log->logdie("can't create new_doc( $uri )"); |
my $doc = $self->{invindex}->new_doc( $uri ) || $log->logdie("can't create new_doc( $uri )"); |
157 |
eval { $doc->set_value('uri', $self->convert($uri) ) }; |
|
158 |
|
sub add_value($$$$$) { |
159 |
|
my ($self,$log,$doc,$n,$v) = @_; |
160 |
|
return unless ($v); |
161 |
|
eval { $doc->set_value($n, $self->convert($v) ) }; |
162 |
|
$log->warn("can't insert: $n = $v") if ($@); |
163 |
|
} |
164 |
|
|
165 |
|
add_value($self,$log,$doc, 'uri', $uri); |
166 |
|
|
167 |
$log->debug("ds = ", sub { Dumper($args->{'ds'}) } ); |
$log->debug("ds = ", sub { Dumper($args->{'ds'}) } ); |
168 |
|
|
184 |
$vals = $self->convert( $vals ) or |
$vals = $self->convert( $vals ) or |
185 |
$log->logdie("can't convert '$vals' to UTF-8"); |
$log->logdie("can't convert '$vals' to UTF-8"); |
186 |
|
|
187 |
eval { $doc->set_value( $tag, $vals ) }; |
add_value($self, $log, $doc, $tag, $vals ); |
188 |
} |
} |
189 |
|
|
190 |
my $text = $args->{'text'}; |
if (my $text = $args->{'text'}) { |
191 |
if ( $text ) { |
add_value($self, $log, $doc, 'bodytext', $text ); |
|
$text = $self->convert( $text ) or |
|
|
$log->logdie("can't convert '$text' to UTF-8"); |
|
|
eval { $doc->set_value( bodytext => $text ) }; |
|
192 |
} |
} |
193 |
|
|
194 |
#$log->debug("adding ", sub { $doc->dump_draft } ); |
#$log->debug("adding ", sub { $doc->dump_draft } ); |
197 |
return 1; |
return 1; |
198 |
} |
} |
199 |
|
|
200 |
|
=head2 finish |
201 |
|
|
202 |
|
Close index |
203 |
|
|
204 |
|
$index->finish; |
205 |
|
|
206 |
|
=cut |
207 |
|
|
208 |
|
sub finish { |
209 |
|
my $self = shift; |
210 |
|
|
211 |
|
$self->_get_logger()->info("finish index writing to disk"); |
212 |
|
$self->{invindex}->finish; |
213 |
|
} |
214 |
|
|
215 |
=head2 convert |
=head2 convert |
216 |
|
|