views:

208

answers:

1

The Lucene documents tell me that "Hits" will be removed from the API in Lucene 3.0.

Deprecated. Hits will be removed in Lucene 3.0. Use search(Query, Filter, int) instead.

The proposed overload limits the number of documents returned to the value of the int.

So my question is: what is the recommended way to perform a search in Lucene with no limit on the number of documents to be returned?

+3  A: 

The highest integer in Java is pretty darned high, you could use Integer.MAX_VALUE for the limit. I bet something else breaks before you actually hit the limit of 2^31-1 (2,147,483,647) documents. :-)

Alternately, you can use a HitCollector: search(Query query, HitCollector results) or search(Query query, Filter filter, HitCollector results); the docs say:

Applications should only use this if they need all of the matching documents

T.J. Crowder
Setting the topcount to a high enough value indeed is the easiest answer. If I really would have needed everything then the custom HitCollector would have been the ideal solution. But i'd rather just use the high-level search api.
Thomas
@Thomas: Yeah, that makes the most sense to me as well. :-)
T.J. Crowder