[KinoSearch] Best way to set default_boolop to 'AND'

Dmitri Tikhonov Dmitri.Tikhonov at vonage.com
Wed Mar 14 10:04:35 PDT 2007


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?



More information about the kinosearch mailing list