lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ard Schrijvers" <>
Subject RE: Calling indexWriter.close() in web app
Date Mon, 09 Jul 2007 08:28:03 GMT

> I'm developing a web app with struts that need to embed lucene
> functionalities. I need that my app adds documents to the 
> index after that a
> document is added (documents are very few, but of large 
> size). I read that i
> have to use a single instance of indexwriter to edit the 
> index. Suppose i
> use a singleton or store indexwriter in the application scope 
> to grant all
> users to use that single instance. 
> My questions are: 
> - when i can close indexwriter to flush changes? 

After you have added documents

> - How to know that an indexwriter has been closed before 
> adding documents to
> it? 

You are using probably a Singleton for it, so I suppose you are totally in charge wether it
has been closed or not. After closing you just set the Singleton indexWriter instance to null
after closing. Then, you open a new one when doing a getInstance on the Singleton.

> - What does it happen if users continue adding documents to 
> the index after
> one user action closed it?

This obviously should not be possible. You should design your Singleton accordingly. Since
you are telling you have very few documents to be indexed, I would rely on synchronized static
functions for adding and deleting documents. If OTOH, you have many documents to add, for
performance reasons an index queue is adviseable

> Please help!

Regards Ard

> Sorry for my bad english.
> -- 
> View this message in context: 
> pp-tf4047813.html#a11497597
> Sent from the Lucene - Java Users mailing list archive at
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message