lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Robert <>
Subject Pagination and Sorting
Date Thu, 01 Oct 2009 11:17:07 GMT
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

Sorting is also no problem - create the Sort object and executing the

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 =, 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!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message