No. You should not do this for every document you add or update. First time, When you open your writer, if the directory is locked, it will throw LockObtainFailedException, In this case, Unlock it and Open the writer again.
Regards Ganesh ----- Original Message ----- From: "Amin Mohammed-Coleman" <[email protected]> To: <[email protected]>; <[email protected]> Sent: Wednesday, July 01, 2009 5:39 PM Subject: Re: IndexWriter > Hi all > > Thanks for your response. I guess when I add or update using the > indexwriter I need to do the following: > > }finally { > if (IndexReader.isLocked(directory)) { > IndexReader.unlock(directory); > } > } > > > Cheers > Amin > > > > On Wed, Jul 1, 2009 at 11:47 AM, Simon Willnauer < > [email protected]> wrote: > >> You might want to take care of the write.lock file in the index >> directory if your application breaks down. If you do not close the >> writer and restart you app you might get an LockObtainFailedException. >> >> simon >> >> On Wed, Jul 1, 2009 at 12:39 PM, Ganesh<[email protected]> wrote: >> > Yes. Single IndexWriter could be maintained in a App and it could be >> closed when the App is shutdown. >> > >> > Regards >> > Ganesh >> > >> > ----- Original Message ----- >> > From: "Amin Mohammed-Coleman" <[email protected]> >> > To: <[email protected]> >> > Sent: Wednesday, July 01, 2009 1:27 PM >> > Subject: IndexWriter >> > >> > >> >> Hi >> >> >> >> This question has probably been asked before so apologies for asking it >> >> again. Just to confirm that it is ok to use a single index writer in a >> web >> >> application and only close that single instance on application shutdown? >> As >> >> the indexwriter is thread safe there is no need for any external >> >> synchronisation. Am I correct in thinking this? >> >> >> >> I have configured via spring a single index writer which is used in the >> >> application and I use the same one for adding and updating documents. >> This >> >> index writer is closed when the spring application context shutsdown. >> >> >> >> >> >> Cheers >> >> Amin >> >> >> > Send instant messages to your online friends >> http://in.messenger.yahoo.com >> > >> > --------------------------------------------------------------------- >> > 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] >> >> > Send instant messages to your online friends http://in.messenger.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
