Dear List,
for the overwhelming majority of my searches, it makes sense to combine
the terms using 'AND', not 'OR'. To do that, I need to replace
'default_boolop' as described in KinoSearch::QueryParser::QueryParser.
However, that class requires that I give it the list of applicable
fields.
What I have come up with is this:
my $r = KinoSearch::Index::IndexReader->new(invindex => INDEX);
# Copied from dump_index:
my @readers = ref $r->{sub_readers} eq 'ARRAY' ?
@{ $r->{sub_readers} } : $r;
my @fields =
map { $_->get_name }
map { $_->get_infos }
map { $_->get_finfos } @readers;
And then:
my $hits = $searcher->search(query =>
KinoSearch::QueryParser::QueryParser->new(
analyzer => $analyzer,
fields => \@fields,
default_boolop => 'AND',
)->parse($query)
);
This is a large departure from the original code:
my $hits = $searcher->search(query => $query);
which does not care if it knows the names of all the fields [1].
Question: is this the best way to do this or am I missing somthing
obvious?
Thank you,
- Dmitri.
1. By the way, why not?
for the overwhelming majority of my searches, it makes sense to combine
the terms using 'AND', not 'OR'. To do that, I need to replace
'default_boolop' as described in KinoSearch::QueryParser::QueryParser.
However, that class requires that I give it the list of applicable
fields.
What I have come up with is this:
my $r = KinoSearch::Index::IndexReader->new(invindex => INDEX);
# Copied from dump_index:
my @readers = ref $r->{sub_readers} eq 'ARRAY' ?
@{ $r->{sub_readers} } : $r;
my @fields =
map { $_->get_name }
map { $_->get_infos }
map { $_->get_finfos } @readers;
And then:
my $hits = $searcher->search(query =>
KinoSearch::QueryParser::QueryParser->new(
analyzer => $analyzer,
fields => \@fields,
default_boolop => 'AND',
)->parse($query)
);
This is a large departure from the original code:
my $hits = $searcher->search(query => $query);
which does not care if it knows the names of all the fields [1].
Question: is this the best way to do this or am I missing somthing
obvious?
Thank you,
- Dmitri.
1. By the way, why not?