__PACKAGE__->mk_accessors(qw(
path
database
+ input
encoding
clean
use KinoSearch::Simple;
use File::Path;
-use Encode qw/from_to/;
+use Encode qw/decode/;
use Data::Dump qw/dump/;
use Storable;
$self->encoding( 'ISO-8859-2' ) unless $self->encoding;
+ ## FIXME we shouldn't re-create whole KinoSearch index every time!
+# $self->clean( 1 );
+
if ( ! -e $self->path ) {
mkpath $self->path || $log->logdie("can't create ", $self->path,": $!");
$log->info("created ", $self->path);
$log->logdie("need id") unless defined $id;
$log->logdie("need ds") unless $ds;
- $log->debug("id: $id ds = ",dump($ds));
-
my $hash = $self->ds_to_hash( $ds, 'search' ) || return;
+ $hash->{id} ||= $id;
$hash->{database} ||= $self->database;
- $hash->{id} ||= $id;
+ $hash->{input} ||= $self->input;
+
+ foreach my $f ( keys %$hash ) {
+ if ( ref($hash->{$f}) eq 'ARRAY' ) {
+ $hash->{$f} = join(' <*> ', @{ $hash->{$f} });
+ }
+# $hash->{$f} = decode( $self->encoding, $hash->{$f} );
+ $self->{field_count}->{$f}++;
+ }
$log->debug("add( $id, ", sub { dump($ds) }," ) => ", sub { dump( $hash ) });
$log->info("indexed ", $self->{count}, " records");
+ $log->debug("field usage: ", dump( $self->{field_count} ));
+
}
=head1 AUTHOR