lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Massart" <dmass...@acm.org>
Subject Re: querying without hits
Date Wed, 15 Oct 2008 09:33:19 GMT
Thanks guys.
Just looking at the examples and I wonder if there is a means to directly
get the total number of hits. Or is it always necessary to search for a few
top docs, get the the total number of hits and then create a new collector
to get all the results?

TopDocCollector collector = new TopDocCollector(5);

searcher.search(query, collector);

int numTotalHits = collector.getTotalHits();

collector = new TopDocCollector(numTotalHits);

searcher.search(query, collector);

ScoreDoc[] hits = collector.topDocs().scoreDocs;

If the later is true, is the code above the best way to do this?

Cheers,

David

On Wed, Oct 15, 2008 at 5:16 AM, Chris Hostetter
<hossman_lucene@fucit.org>wrote:

>
> : Could one of you point me to an example of code for querying without
> using
> : the deprecated class Hits ?
>
> The demo code included with Lucene releases was updated in Lucene 2.4 so
> that it does not use the Hits class.
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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