);
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/
+ backupnum
+ 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(
my $sort_spec = KinoSearch::Search::SortSpec->new( rules => $rules );
-# $q =~ s/(.)/$1 /g;
+ my $split = $q;
+ $split =~ s/(.)/$1 /g; # _file_path_split
+ 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(
- query => $q,
+ query => m/:/ ? $q : $query,
+ offset => $offset,
+ num_wanted => $on_page,
sort_spec => $sort_spec,
);
my $results;
while ( my $hit = $hits->next ) {
-warn "XXX ",dump($hit);
+ warn "## hit = ",dump($hit) if $ENV{DEBUG};
push @$results, $hit;
}