implement numeric padding
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 11 Jan 2011 18:02:27 +0000 (18:02 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 11 Jan 2011 18:02:27 +0000 (18:02 +0000)
lib/BackupPC/Search/KinoSearch.pm

index 30cc073..e6f7c6a 100644 (file)
@@ -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 );
 
 }