[ 
https://issues.apache.org/jira/browse/LUCENE-3180?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045846#comment-13045846
 ] 

Simon Willnauer commented on LUCENE-3180:
-----------------------------------------

Danny, this is all expected behavior. I am going to close this issue now since 
there is no bug here whatsoever. Please can you phrase quickly what you are 
trying to do and I am happy to explain best practice on the user list. Thanks.

> Can't delete a document using deleteDocument(int docID) if using IndexWriter 
> AND IndexReader
> --------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-3180
>                 URL: https://issues.apache.org/jira/browse/LUCENE-3180
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: core/index
>    Affects Versions: 3.2
>         Environment: Windows 
>            Reporter: Danny Lade
>         Attachments: ImpossibleLuceneCode.java
>
>
> It is impossible to delete a document with "reader.deleteDocument(docID)" if 
> using an IndexWriter too.
> using:
> {code:java}
> writer = new IndexWriter(directory, config);
> reader = IndexReader.open(writer, true);
> {code}
> results in:
> {code:java}
>   Exception in thread "main" java.lang.UnsupportedOperationException: This 
> IndexReader cannot make any changes to the index (it was opened with readOnly 
> = true)
>       at 
> org.apache.lucene.index.ReadOnlySegmentReader.noWrite(ReadOnlySegmentReader.java:23)
>       at 
> org.apache.lucene.index.ReadOnlyDirectoryReader.acquireWriteLock(ReadOnlyDirectoryReader.java:43)
>       at 
> org.apache.lucene.index.IndexReader.deleteDocument(IndexReader.java:1067)
>       at 
> de.morpheum.morphy.ImpossibleLuceneCode.main(ImpossibleLuceneCode.java:60)
> {code}
> and using:
> {code:java}
> writer = new IndexWriter(directory, config);
> reader = IndexReader.open(directory, false);
> {code}
>   
> results in:
> {code:java}
>   org.apache.lucene.store.LockObtainFailedException: Lock obtain timed out: 
> NativeFSLock@S:\Java\Morpheum\lucene\write.lock
>       at org.apache.lucene.store.Lock.obtain(Lock.java:84)
>       at 
> org.apache.lucene.index.DirectoryReader.acquireWriteLock(DirectoryReader.java:765)
>       at 
> org.apache.lucene.index.IndexReader.deleteDocument(IndexReader.java:1067)
>       at 
> de.morpheum.morphy.ImpossibleLuceneCode.main(ImpossibleLuceneCode.java:69)
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to