Hi,
To answer my question myself. If there is no way to retrieve this from
the $searcher->hits object, it could be done by doing two queries, one
with MatchAllQuery and the actual query. I just tried this (below) and
that works. However, it's not ideal.
$phrase_query = $queryparser->parse("some phrase");
my $match_all_query = Lucy::Search::MatchAllQuery->new;
my $hits = $self->env->current_searcher->hits(
query => $phrase_query,
sort_spec => $sort_spec,
offset => 0,
num_wanted => 1000000000,
);
my $all_hits = $self->env->current_searcher->hits(
query => $match_all_query,
sort_spec => $sort_spec,
offset => 0,
num_wanted => 1000000000,
);
my $index = -1;
my $found_indices = [ ];
SMALL: while( my $hit = $hits->next ) {
while( my $all_hit = $all_hits->next ) {
$index++;
if ( $hit->{ message_id } eq $all_hit->{ message_id } ) {
say "I'm a hit and number $index in order of publication.";
next SMALL;
}
}
}
Kind regards,
Arjan.
On 08/06/2012 12:35 PM, arjan wrote:
Hi all,
Would it be somehow possible to retrieve the rownumber or count of a
hit in a sorted search?
Suppose this is stored in lucy in this order: (simple example values
for epoch)
color epoch
red 1
blue 2
green 0
Suppose I search for blue and I sort by epoch. I would get 1 result
and this would be the 1st or 3rd item of all my sorted documents.
(depending on using reverse or not) Is there a way to find out that it
the hit is the 1st or 3rd item?
And - by the way - I was very happy with Peters post saying that range
queries need to be fixed width. I never experienced a problem, because
I never used epoch values before September 9th 2001, (1000000000). And
just before I was about doing this, I read his email. Talking about
just-in-time information. ;)
I assume the same goes for SortRules, meaning that I have to enter
epoch values, and other numerical values, into the lucy as fixed width
entries. Right?
Kind regards,
Arjan Widlak.
--
Met vriendelijke groet,
Arjan Widlak
Bezoek onze site op:
http://www.unitedknowledge.nl
United Knowledge, inhoud en techniek
Bilderdijkstraat 79N
1015 CT Amsterdam
T +31 (0)20 737 1851
F +31 (0)84 877 0399
[email protected]
http://www.unitedknowledge.nl
M +31 (0)6 2427 1444
E [email protected]