6 |
|
|
7 |
use strict; |
use strict; |
8 |
use blib './lib'; |
use blib './lib'; |
9 |
use Grep::Search; |
use Grep::Search::KinoSearch; |
10 |
use KinoSearch::Highlight::Highlighter; |
use KinoSearch::Highlight::Highlighter; |
11 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
12 |
|
|
15 |
die "usage: $0 /path/to/index 'search query'\n" unless ( $index_path && $query_string ); |
die "usage: $0 /path/to/index 'search query'\n" unless ( $index_path && $query_string ); |
16 |
|
|
17 |
my $searcher = KinoSearch::Searcher->new( |
my $searcher = KinoSearch::Searcher->new( |
18 |
invindex => Grep::Search::Schema->open( $index_path ) |
invindex => Grep::Search::KinoSearch::Schema->open( $index_path ) |
19 |
); |
); |
20 |
|
|
21 |
my @fields = ( qw/ title link content summary category author / ); |
my @fields = ( qw/ title link content summary category author / ); |
22 |
my @excerpt_fields = ( qw/ content summary / ); |
my @excerpt_fields = ( qw/ content summary / ); |
23 |
|
|
24 |
my $query_parser = KinoSearch::QueryParser->new( |
my $query_parser = KinoSearch::QueryParser->new( |
25 |
schema => Grep::Search::Schema->new, |
schema => Grep::Search::KinoSearch::Schema->new, |
26 |
fields => \@fields, |
fields => \@fields, |
27 |
); |
); |
28 |
$query_parser->set_heed_colons(1); # enable field:value AND/OR/NOT syntax |
$query_parser->set_heed_colons(1); # enable field:value AND/OR/NOT syntax |