You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Christian (JIRA)" <ji...@apache.org> on 2013/06/14 14:16:20 UTC
[jira] [Created] (LUCENE-5058) IOException when trying to delete
data from index
Christian created LUCENE-5058:
---------------------------------
Summary: IOException when trying to delete data from index
Key: LUCENE-5058
URL: https://issues.apache.org/jira/browse/LUCENE-5058
Project: Lucene - Core
Issue Type: Bug
Components: core/index
Affects Versions: 4.3
Environment: Windows 7
Reporter: Christian
I have a small test prog which inserts some data in an index and after that, opens a searcher from the uncommitted index to search on and output the result to std.out. The Searcher is immediately closed. Then, i call deleteAll() on the index but it encounters an IOException stating that the index files could not be removed. I have investigated with Sysinternals and it says the file is still locked despite the fact that the index searcher is correctly closed. If i call deleteAll() without opening a searcher before it just works fine as expected. This seems to be a bug in Lucene, since closing the index searcher makes it impossible to delete the index.
Here is the source code:
<code>
public class LuceneTest {
private Directory dir;
private IndexWriter writer;
public void addDocs(long value) throws IOException {
Document doc = new Document();
doc.add(new LongField("ID", value, Field.Store.YES));
writer.deleteDocuments(new Term("ID", "1"));
writer.addDocument(doc);
}
public void search() throws IOException {
IndexSearcher searcher = new IndexSearcher(DirectoryReader.open(writer, false));
TopDocs results = searcher.search(NumericRangeQuery.newLongRange("ID", 1L, 2L, true, true), 1);
for ( ScoreDoc sc : results.scoreDocs) {
System.out.println(searcher.doc(sc.doc));
}
searcher.getIndexReader().close();
}
public static void main(String[] args) throws IOException {
new LuceneTest();
}
public LuceneTest() throws IOException {
dir = FSDirectory.open(new File("test"));
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, new StandardAnalyzer(Version.LUCENE_43));
config.setInfoStream(System.out);
writer = new IndexWriter(dir, config);
addDocs(1L);
search();
//writer.commit(); -- If i call commit after search, then no IOException occurrs!
writer.deleteAll();
}
}
</code>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org