From ae81c69bf053eed787bac83c224225446ac07449 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 11 Jan 2011 18:02:27 +0000 Subject: [PATCH 1/1] implement numeric padding --- lib/BackupPC/Search/KinoSearch.pm | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/BackupPC/Search/KinoSearch.pm b/lib/BackupPC/Search/KinoSearch.pm index 30cc073..e6f7c6a 100644 --- a/lib/BackupPC/Search/KinoSearch.pm +++ b/lib/BackupPC/Search/KinoSearch.pm @@ -46,6 +46,18 @@ sub indexer { my $num_type = KinoSearch::Plan::Int64Type->new( sortable => 1 ); my $sort_type = KinoSearch::Plan::StringType->new( sortable => 1 ); # non-tokenized +=for numeric-no-padding + fid + shareid + type + backupnum +=cut + $self->{numeric_padding} = [ qw/ + backup_date + date + size + / ]; + # numeric $schema->spec_field( name => $_, type => $string_type ) foreach ( qw/ backup_date @@ -120,10 +132,14 @@ sub add_doc { $path =~ s/(.)/$1 /g; # XXX our tokenize $row->{_file_path_split} = $path; - warn "XXX ",dump($row) if $ENV{DEBUG}; - $self->{stats}->{add_doc}++; + foreach my $col ( @{ $self->{numeric_padding} } ) { + $row->{$col} = sprintf "%011d", $row->{$col}; + } + + warn "XXX ",dump($row) if $ENV{DEBUG}; + $self->indexer->add_doc( $row ); } -- 2.20.1