Erik, thanks! You are right! It is not a good idea to hold on a hits since the index will be updated. So, when i keep a hits, and then the index is updated, the searcher will be auto-updated,too. rigtht?
Best Regards. jacky ----- Original Message ----- From: "Erik Hatcher" <[EMAIL PROTECTED]> To: <java-user@lucene.apache.org> Sent: Wednesday, September 06, 2006 4:15 PM Subject: Re: Keep hits in results On Sep 6, 2006, at 12:56 AM, jacky wrote: > hi, > The following words are quoted from "lucene in action": > "There are a couple of implementation approaches: > 1. Keep the original Hits and IndexSearcher instances available > while the > user is navigating the search results. > 2. Requery each time the user navigates to a new page. > It turns out that requerying is most often the best solution. > Requerying eliminates > the need to store per-user state. In a web application, staying > stateless (no > HTTP session) is often desirable. Requerying at first glance seems > a waste, but > Lucene’s blazing speed more than compensates. " > > I am confused about this paragraph. Since Hits is just a simple > container of pointers > to ranked search results, it doesn't load from the index all > documents that match a query, > but only a small portion of them at a time. If we requery, we will > get a new hits, why not > just keeping the orginal Hits which will not waste much memory. Requerying helps avoid server-side sessions in a web application. Hits requires the same IndexSearcher, but in cases where the index is changing and a new IndexSearcher is being swapped in, it requires more management to keep old IndexSearcher's around until they are no longer needed. I prefer the simplicity of requerying until there is actually a performance issue to address. There is nothing wrong with the alternative of keeping Hits around, its just not as simple. Erik --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]