Erik, thanks. U r right. Once excuting the search action, I will check whether this IndexReader still works on a current version of the index by IndexSearcher#isCurrent(). If not I will open a new IndexSearcher. And now it works well.
But I want to know that if index update action offen happens, the IndexSearcher also need create many times, what influence well be caused on my blog system. Have u know something about it. Best regards. >After indexing, you have to open a new IndexSearcher to in order to see new > documents. > > Erik > > >On Apr 9, 2007, at 5:25 AM, anson wrote: > >> >> I have build a blog project under tomcat5.5 with Lucene2.0. >> And I want to search my blog by full text, but there is somthing wrong: >> >> ---------------------------------------------- >> The project flow: >> >> (1) On tomcat start I wrote a listener to create a index file if the >> index is never created.(It's works well) >> >> >> (2) When I create/update/delete an article on the blog, I wrote a method >> to update the index.(It's also works well) >> >> (3) Then I want to search the new/updated article in the front of my >> blog page. But I can't get the new article. But when I restart the >> tomcat, I can get the new one that I want. Why. >> >> >> ----------------------------------------------- >> The index update flow: >> >> (1) Firsrt I delete the old document in index: >> >> IndexReader reader = >> IndexReader.open($INDEX_DIRECTORY); >> >> Term term = new Term("INDEX_ID", $entryId); >> >> if (term != null) { >> reader.deleteDocuments(term); >> } >> >> //finally: >> reader.close(); >> >> >> (2) Add the article to the index: >> // Get the singleton IndexWriter instance >> IndexWriter writer = >> IndexManager.getInstance().getIndexWriter(); >> >> // add document >> // Document() is method of make Lucene document >> writer.addDocument(Document($EntryBean)); >> >> writer.optimize(); >> >> >> // finally: >> writer.close(); >> >> >> Could anybody tell me anything can help me out. Or I made a wrong flow? >> >> >> Best regards. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]