Are you absolutely certain you are closing the IndexReader after each
iteration?  That exception looks like there is still a file open...

Committing after every added document is hideously inefficient
(though, should not cause exceptions like what you're seeing).  It's
best to commit (or, simply close), at the end, when you're just
building up a new index.

It's also not a good idea to sync(IndexWriter), because that can lead
to deadlock (Lucene syncs on it internally).  Further, it's not
necessary since IW can take advantage of concurrency when multiple
threads call addDocument at once.

Mike

On Sat, Nov 21, 2009 at 4:46 AM, Simon Willnauer
<[email protected]> wrote:
> Try to switch you AntiVirus SW off I you have any.
>
> simon
>
> 2009/11/21 Fabrício Raphael <[email protected]>:
>> This hapened only on Windows, on Ubuntu it don't happen.
>>
>> And I corrected this problem by removing the commit, and put it in the end
>> of the addition of all documents.
>>
>> On Fri, Nov 20, 2009 at 9:14 PM, Erick Erickson 
>> <[email protected]>wrote:
>>
>>> What operating system are you running on? This sounds like Windows behavior
>>> when some other process is holding the file open.....
>>>
>>> Erick
>>>
>>> 2009/11/20 Fabrício Raphael <[email protected]>
>>>
>>> > Hi,
>>> >
>>> > I am evaluating several search algoritms, and I iterate on each. In each
>>> > interation I delete the index directory, index the docs and I run the
>>> > evaluation on the algoritm. The end of the iteration I close the
>>> > indexReader.
>>> >
>>> > Then, in the second iteration the following error occurs int the doc 1154
>>> > indexing:
>>> >
>>> > adding docs\1148
>>> > adding docs\1149
>>> > adding docs\1150
>>> > adding docs\1151
>>> > adding docs\1152
>>> > adding docs\1153
>>> > adding docs\1154
>>> > java.io.IOException: Cannot overwrite: index\_zk.cfs
>>> >    at
>>> org.apache.lucene.store.FSDirectory.initOutput(FSDirectory.java:362)
>>> >    at
>>> >
>>> >
>>> org.apache.lucene.store.SimpleFSDirectory.createOutput(SimpleFSDirectory.java:58)
>>> >    at
>>> >
>>> >
>>> org.apache.lucene.index.CompoundFileWriter.close(CompoundFileWriter.java:150)
>>> >    at
>>> >
>>> >
>>> org.apache.lucene.index.DocumentsWriter.createCompoundFile(DocumentsWriter.java:618)
>>> >    at
>>> >
>>> org.apache.lucene.index.IndexWriter.doFlushInternal(IndexWriter.java:4320)
>>> >    at org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:4174)
>>> >    at org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:4165)
>>> >    at
>>> > org.apache.lucene.index.IndexWriter.prepareCommit(IndexWriter.java:4055)
>>> >    at org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:4118)
>>> >    at org.apache.lucene.index.IndexWriter.commit(IndexWriter.java:4096)
>>> >
>>> > This is the code:
>>> >
>>> > public void addDocument(Document doc) throws CorruptIndexException,
>>> >            IOException {
>>> >        synchronized (getIndexWriter()) {
>>> >                getIndexWriter().addDocument(doc);
>>> >                getIndexWriter().commit();
>>> >        }
>>> >    }
>>> >
>>> >
>>> > Can any help me?
>>> >
>>> > Now Thanks!
>>> >
>>> > --
>>> > Fabrício Raphael Silva Ferreira
>>> >
>>>
>>
>>
>>
>> --
>> Fabrício Raphael
>>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to