Otis Gospodnetic wrote:
Hi,
Check the Hits javadoc:
* @deprecated Hits will be removed in Lucene 3.0. <p>
* Instead e. g. [EMAIL PROTECTED] TopDocCollector} and [EMAIL PROTECTED] TopDocs}
can be used:<br>
* <pre>
* TopDocCollector collector = new TopDocCollector(hitsPerPage);
* searcher.search(query, collector);
* ScoreDoc[] hits = collector.topDocs().scoreDocs;
* for (int i = 0; i < hits.length; i++) {
* int docId = hits[i].doc;
* Document d = searcher.doc(docId);
* // do something with current hit
* ...
* </pre>
Related topic: what if we need all the hits and not just the first 100?
TopDocCollector has a couple of drawbacks, one is that you need to know
the number of hits before the query, and you can't overallocate as it
will run you out of memory. I take it this is the suggested workaround
for that:
TopDocCollector collector = new TopDocCollector(PAGE_SIZE);
searcher.search(query, collector);
TopDocCollector collector2 = new TopDocCollector(
collector.getTotalHits());
searcher.search(query, collector2);
And then wrap it up such that the initial search's results are
immediately available and the rest load on demand? Sounds almost
exactly like Hits to me though, with the drawback being we have to write
it ourselves instead of it being part of Lucene.
Or do we make a replacement for TopDocCollector which doesn't have this
drawback, and uses an alternative for PriorityQueue which allows its
array to grow?
Daniel
--
Daniel Noll
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]