lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Date Thu, 09 Dec 2004 10:03:50 GMT
On Dec 9, 2004, at 2:59 AM, Karthik N S wrote:
> Apologies...............

Again, no need to apologize for asking questions.  Just ask :)

> One question for the form [ Especially Erik]

And no need to address anyone specifically here, though I'm happy to 
help and am always here listening.

> Question
> How to Display the Contents for the Hits in  Incremental order ?
> [ Each Time a re hit to the Mergerindex with Incremental X value ].
> This would solve the problem of Out of Memory by prefetching all the 
> hit in
> one strait go process.

It is unwise, as you've seen, to prefetch the documents from Hits.  
Hits is designed for exactly what you're after.  You can get the number 
of hits using hits.size().

My recommendation for paging through search results (and I'm using this 
extensively myself) in a web application is to simply display 25 
results on one page - iterating *only* through those 25 desired.  The 
link (or button) the user presses to go to the next or previous page 
passes the page number and query (search.jsp?query=some+query&page=2).  
Your server-side logic will search again, and start the hits iteration 
for 25 entries at 25 * the value of the page attribute.

Lucene is plenty fast enough to allow this to work without much 
concern.  Since your index is getting somewhat large, though, you 
probably do want to keep a persistent instance of IndexSearcher 
available on the server (perhaps in application scope).  But a first 
pass implementation don't concern yourself with even that - just 
re-instantiate IndexSearcher for every search and see how fast things 
are.  If its fast enough, leave well enough alone.

Does this all make sense?


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

View raw message