You could get the hits in a collector and pass the sort to the collector as it would be the collect function that handles the sorting.
searcherObject.search(query,collector); Hope that gives you some headway. :) -- Anshum Gupta Naukri Labs! http://ai-cafe.blogspot.com The facts expressed here belong to everybody, the opinions to me. The distinction is yours to draw............ On Thu, Oct 1, 2009 at 4:47 PM, Christian Robert <cr_use...@arcor.de> wrote: > Hello everybody, > > I'm looking at quite an interesting challenge right now, so I > hope that somebody out there will be able to assist me. > > What I'm trying to do is returning search results both sorted and > paginated. So far I haven't been able to come up with a working solution. > > Pagination without sorting is no problem - simply looping through the > document identifiers and grabbing the documents within my "pagination > window". > > Sorting is also no problem - create the Sort object and executing the > search. > > However, when using a Sort I always get a TopDocs object in which all > the identifiers of the documents are contained. No problem when dealing > with a small index, but I've some 700.000 documents indexed and each > time I'm trying to call > > TopDocs topDocs = > indexSearcher.search(query, null, Integer.MAX_VALUE, sort); > > I'm ending up with an OutOfMemoryError. > > So it seems that Lucene needs all the documents loaded into memory for > the sorting to work where in contrast I only want to load the documents > to be displayed in the current pagination window. > > Am I lost here and have to find another way or is there a working > solution to combine sorting and pagination? > > Thanks in advance! > Chris > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > >