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.

Reply via email to