lucy-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saurabh Vasekar <svase...@listenlogic.com>
Subject [lucy-user] Problem in implementing NOTQuery
Date Thu, 14 Jun 2012 18:25:17 GMT
Hello,

I want to implement the following specification.
My indexed document has 2 fields -- field1 and field2. I formed the
following query -

my $query1 = Lucy::Search::TermQuery->new(
         field => 'field1',
         term => 'term1'.
);

my $query2 = Lucy::Search::TermQuery->new(
        field => 'field2',
        term => 'term2',
);

my $query1NOT = Lucy::Search::NOTQuery->new(
        negated_query => $query1,
);

my $query = Lucy::Search::ANDQuery->new(
       children => [$query1NOT, $query2 ]
);

my $hits = $searcher->hits(
        query => $query,
        offset => $offset,
        num_wanted => $page_size,
);

The problem is that query1 is not being negated. I am getting results which
have both term1 and term2 whereas the result should contain only term2.

Is my implementation wrong? Is there any better method to do this?

Thank you.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message