The Hits class was deprecated at some point and has been removed from recent releases.
The 2.9.3 javadoc at http://lucene.apache.org/java/2_9_3/api/core/org/apache/lucene/search/Hits.html shows a little code sample TopDocs topDocs = searcher.search(query, numHits); ScoreDoc[] hits = 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 ... you just need to replace numHits with a suitable value e.g. 1223 and replace the for loop with something like int docId = hits[57].doc; Document d57 = searcher.doc(docId); docId = hits[1223].doc; Document d1223 = searcher.doc(docId); Higher values for numHits may have adverse effects on performance, but if you need them, you need them. -- Ian. On Sat, Oct 15, 2011 at 7:47 PM, Herb Roitblat <h...@orcatec.com> wrote: > I have an application where I would like to pick one document from somewhere > in the list of search results. For example, I would like to retrieve one of > the results at rank 57, another at rank 1223, etc. I'm not real clear on > how to do it. > > > I have seen some things on simulating pagination with Lucene, some code on > using hitlists and some comments on hitlists being deprecated. > > I have seen the class TopDocsCollector and the method > |*topDocs > <http://lucene.apache.org/java/2_9_3/api/core/org/apache/lucene/search/TopDocsCollector.html#topDocs%28int,%20int%29>*(int > start, int howMany)| > Returns the documents in the rage [start .. > > I can see using topDocs with howMany = 1, but I'm wondering whether that > means that the system iterates over the entire return list until it finds > the the one at rank start? > > Is this the best way to do it? > > I'm using pyLucene 2.9 on Ubuntu 10.04. > > Thanks for any pointers. > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org