projects
/
BackupPC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
don't dump hits to STDERR without DEBUG env variable
[BackupPC.git]
/
lib
/
BackupPC
/
Search
/
KinoSearch.pm
diff --git
a/lib/BackupPC/Search/KinoSearch.pm
b/lib/BackupPC/Search/KinoSearch.pm
index
1d1b256
..
91f488d
100644
(file)
--- a/
lib/BackupPC/Search/KinoSearch.pm
+++ b/
lib/BackupPC/Search/KinoSearch.pm
@@
-43,22
+43,34
@@
sub indexer {
);
my $blob_type = KinoSearch::Plan::BlobType->new( stored => 1 );
my $string_type = KinoSearch::Plan::StringType->new; # non-tokenized
);
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
# numeric
$schema->spec_field( name => $_, type => $string_type ) foreach ( qw/
backup_date
- backupnum
- date
fid
shareid
fid
shareid
- size
type
/ );
# non-tokenized strings
$schema->spec_field( name => $_, type => $string_type ) foreach ( qw/
type
/ );
# non-tokenized strings
$schema->spec_field( name => $_, type => $string_type ) foreach ( qw/
- _uri 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/
+ backupnum
+ date
+ size
/);
# tokenized magic columns for infix search
/);
# tokenized magic columns for infix search
@@
-134,9
+146,13
@@
sub search {
my $sort_spec = KinoSearch::Search::SortSpec->new( rules => $rules );
my $sort_spec = KinoSearch::Search::SortSpec->new( rules => $rules );
- $q =~ s/(.)/$1 /g; # _file_path_split
+ my $split = $q;
+ $split =~ s/(.)/$1 /g; # _file_path_split
+ $split = qq{"$split"}; # exact ordering
my $hits = $self->searcher->hits(
my $hits = $self->searcher->hits(
- query => $q,
+ query => $split,
+ offset => $offset,
+ num_wanted => $on_page,
sort_spec => $sort_spec,
);
sort_spec => $sort_spec,
);
@@
-147,7
+163,7
@@
sub search {
my $results;
while ( my $hit = $hits->next ) {
my $results;
while ( my $hit = $hits->next ) {
-
warn "XXX ",dump($hit)
;
+
warn "## hit = ",dump($hit) if $ENV{DEBUG}
;
push @$results, $hit;
}
push @$results, $hit;
}