Hi Peter,
When I run the program below for different queries, it gives me different
values for $hit_count and number of elements in the array @doc_ids . @doc_ids
always shows 10 elements even for different queries, while $hit_count value
changes with query. May be I am missing something.
Thanks, Anil
my $searcher = Lucy::Search::IndexSearcher->new(
index => $path_to_index,
);
my $qparser = Lucy::Search::QueryParser->new(
schema => $searcher->get_schema,
default_boolop => 'OR',
);
my $query = $qparser->parse('query');
my $hits = $searcher->hits(
query => $query,
);
my $hit_count = $hits->total_hits;
print "$hit_count\n";
my @doc_ids;
while ( my $hit_doc = $hits->next ) {
push @doc_ids, $hit_doc->get_doc_id();
}
print "@doc_ids\n";
________________________________
From: Peter Karman <[email protected]>
To: [email protected]
Sent: Tuesday, September 24, 2013 1:02 PM
Subject: Re: [lucy-user] document IDs
On 9/24/13 12:44 PM, Anil Pachuri wrote:
> # something like:
> my $docIDs = $hits->doc_ids;
>
my @doc_ids;
while ( my $hit_doc = $hits->next ) {
push @doc_ids, $hit_doc->get_doc_id();
}
https://metacpan.org/module/Lucy::Document::Doc
-- Peter Karman . http://peknet.com/ . [email protected]