lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: [lucy-user] Running query string thru Analyzer?
Date Sat, 17 Jan 2015 17:19:45 GMT
On Sat, Jan 17, 2015 at 8:58 AM, Nick Wellnhofer <wellnhofer@aevum.de> wrote:

> Oops, I just saw that queries for "Foo" don't work either, so scratch that.
> Can you show us your indexing and querying code or even a self-contained
> test case?

The issue is probably that TermQuery's constructor takes exactly what you give
it, which may not match what's in the index.  In this case, `foo` is in the
index, so queries for `Foo` don't work.

A QueryParser will probably give Gerald what he wants, because it will apply
the appropriate Analyzer.

  use Lucy;
  use Data::Dumper qw( Dumper );
  my $searcher = Lucy::Search::IndexSearcher->new(index => '/path/to/index');
  my $qparser = Lucy::Search::QueryParser->new(
    schema => $searcher->get_schema,
    fields => ['content'],  # optional, try without this.
  );
  my $query = $qparser->parse("Foo");
  warn Dumper($query->dump);

Marvin Humphrey

Mime
View raw message