You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by vcampa <ca...@interfree.it> on 2007/07/09 10:10:44 UTC

Calling indexWriter.close() in web app

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? 
- How to know that an indexwriter has been closed before adding documents to
it? 
- What does it happen if users continue adding documents to the index after
one user action closed it?

Please help!

Sorry for my bad english.
-- 
View this message in context: http://www.nabble.com/Calling-indexWriter.close%28%29-in-web-app-tf4047813.html#a11497597
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Calling indexWriter.close() in web app

Posted by Mark Miller <ma...@gmail.com>.
The lock file is only for Writers. The lock file ensures that even two 
writers from two JVM's will not step on each other. Readers do not care 
about what the writers are doing or whether there is a lock file...even 
more so with the new generational files i believe.

- Mark

vcampa wrote:
> Steinert, Fabian wrote:
>   
>> Hi,
>> you do not need to writer.close() the IndexWriter at all to make changes
>> visible.
>> When IndexWriter is constructed with autoCommit = true flag set,
>> calling writer.flush() will do.
>>
>>     
>
> Ok, but what about the write.lock? IndexWriter releases its write.lock only
> when closed, so i think problems may begin when i try to open IndexReader on
> a locked index. I'm still confused... help.
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: Calling indexWriter.close() in web app

Posted by vcampa <ca...@interfree.it>.

Steinert, Fabian wrote:
> 
> Hi,
> you do not need to writer.close() the IndexWriter at all to make changes
> visible.
> When IndexWriter is constructed with autoCommit = true flag set,
> calling writer.flush() will do.
> 

Ok, but what about the write.lock? IndexWriter releases its write.lock only
when closed, so i think problems may begin when i try to open IndexReader on
a locked index. I'm still confused... help.

-- 
View this message in context: http://www.nabble.com/Calling-indexWriter.close%28%29-in-web-app-tf4047813.html#a11538916
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


RE: Calling indexWriter.close() in web app

Posted by "Steinert, Fabian" <Fa...@fokus.fraunhofer.de>.
Hi,
 
you do not need to writer.close() the IndexWriter at all to make changes visible.
 
When IndexWriter is constructed with autoCommit = true flag set,
calling writer.flush() will do.
 
This way you can keep your single IndexWriter at App-level handling all the synchonization.
 
Have a look at the IndexWriter API Spec, too.
 
Hope im right with this and it helps you,
Fabian
 

________________________________

Von: vcampa [mailto:campanile@interfree.it]
Gesendet: Mo 09.07.2007 10:10
An: java-user@lucene.apache.org
Betreff: Calling indexWriter.close() in web app




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?
- How to know that an indexwriter has been closed before adding documents to
it?
- What does it happen if users continue adding documents to the index after
one user action closed it?

Please help!

Sorry for my bad english.
--
View this message in context: http://www.nabble.com/Calling-indexWriter.close%28%29-in-web-app-tf4047813.html#a11497597
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org