construct query parser manually
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 9 Jan 2011 21:08:17 +0000 (21:08 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 9 Jan 2011 21:08:17 +0000 (21:08 +0000)
lib/BackupPC/Search/KinoSearch.pm

index 91f488d..7d37191 100644 (file)
@@ -148,9 +148,18 @@ sub search {
 
        my $split = $q;
        $split =~ s/(.)/$1 /g; # _file_path_split
 
        my $split = $q;
        $split =~ s/(.)/$1 /g; # _file_path_split
-       $split = qq{"$split"}; # exact ordering
+       my $split_query = KinoSearch::Search::TermQuery->new( field => '_file_path_split', term => $split );
+#warn "XXX ",dump($split_query);
+
+
+       my $query_parser = KinoSearch::Search::QueryParser->new(
+               schema => $self->searcher->get_schema,
+               fields => ['_file_path_split'],
+       );
+       my $query = $query_parser->parse( '"' . $split . '"' );
+
        my $hits = $self->searcher->hits(
        my $hits = $self->searcher->hits(
-               query => $split,
+               query => m/:/ ? $q : $query,
                offset => $offset,
                num_wanted => $on_page,
                sort_spec => $sort_spec,
                offset => $offset,
                num_wanted => $on_page,
                sort_spec => $sort_spec,