X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FSearch%2FKinoSearch.pm;h=d12577d3d6cf9b2e22489f0a5543f2c85cd9b3af;hp=dcbb74910924d841d2449837ff38d159e9e6a232;hb=316ee1fea2346566054cdab9cfecc0a8b2f662dd;hpb=a533d7e84363f1c0400b93fa522322044da1a96c diff --git a/lib/BackupPC/Search/KinoSearch.pm b/lib/BackupPC/Search/KinoSearch.pm index dcbb749..d12577d 100644 --- a/lib/BackupPC/Search/KinoSearch.pm +++ b/lib/BackupPC/Search/KinoSearch.pm @@ -43,22 +43,39 @@ sub indexer { ); my $blob_type = KinoSearch::Plan::BlobType->new( stored => 1 ); my $string_type = KinoSearch::Plan::StringType->new; # non-tokenized - my $num_type = KinoSearch::Plan::Int64Type->new; + my $num_type = KinoSearch::Plan::Int64Type->new( sortable => 1 ); + my $sort_type = KinoSearch::Plan::StringType->new( sortable => 1 ); # non-tokenized + # numeric $schema->spec_field( name => $_, type => $string_type ) foreach ( qw/ backup_date backupnum - date fid shareid - size type / ); + # non-tokenized strings $schema->spec_field( name => $_, type => $string_type ) foreach ( qw/ - _uri _file_path_split filepath hname sname + _uri + hname /); + # sortable + $schema->spec_field( name => $_, type => $sort_type ) foreach (qw/ + sname + filepath + /); + + # sortable numeric + $schema->spec_field( name => $_, type => $sort_type ) foreach (qw/ + date + size + /); + + # tokenized magic columns for infix search + $schema->spec_field( name => '_file_path_split', type => $ft_type ); + # $schema->spec_field( name => '_doc', type => $blob_type ); my $indexer = KinoSearch::Index::Indexer->new( @@ -129,9 +146,13 @@ sub search { my $sort_spec = KinoSearch::Search::SortSpec->new( rules => $rules ); -# $q =~ s/(.)/$1 /g; + my $split = $q; + $split =~ s/(.)/$1 /g; # _file_path_split + $split = qq{"$split"}; # exact ordering my $hits = $self->searcher->hits( - query => $q, + query => $split, + offset => $offset, + num_wanted => $on_page, sort_spec => $sort_spec, );