You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Cam Bazz <ca...@gmail.com> on 2008/09/16 04:42:41 UTC
TopDocs question
Hello,
Could it harm if I make a
searcher.search(query, Integer.MAX_VALUE) ?
I just need to make a query to get the number of hits in this case,
but I dont know what the max hits will be.
Also When I make a topdocs.totalHits is that same as topdocs.scoreDocs.length()?
Best.
-C.A.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: TopDocs question
Posted by Cam Bazz <ca...@gmail.com>.
Yes, I looked into implementing a custom collector that would return
number of hits, but - I could not.
collect() can not access anything that is final, and final can not be
incremented.
Any ideas?
Best.
On Tue, Sep 16, 2008 at 6:05 AM, Daniel Noll <da...@nuix.com> wrote:
> Cam Bazz wrote:
>>
>> Hello,
>>
>> Could it harm if I make a
>>
>> searcher.search(query, Integer.MAX_VALUE) ?
>>
>> I just need to make a query to get the number of hits in this case,
>> but I dont know what the max hits will be.
>
> PriorityQueue will attempt to allocate an array of that size.
>
> But if you only need to know the *number* of hits, and don't need the hits
> themselves, then you should just use a custom HitCollector which increments
> a counter. It will run much faster.
>
> Daniel
>
>
> --
> Daniel Noll
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: TopDocs question
Posted by Daniel Noll <da...@nuix.com>.
Cam Bazz wrote:
> Hello,
>
> Could it harm if I make a
>
> searcher.search(query, Integer.MAX_VALUE) ?
>
> I just need to make a query to get the number of hits in this case,
> but I dont know what the max hits will be.
PriorityQueue will attempt to allocate an array of that size.
But if you only need to know the *number* of hits, and don't need the
hits themselves, then you should just use a custom HitCollector which
increments a counter. It will run much faster.
Daniel
--
Daniel Noll
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org