Hi,

I have a single IndexWriter object which I use to update
the index.  After each update, I'd like to query the index
using IndexReader and IndexSearcher objects.

When I try to do that I get java.io.FileNotFoundException:
/tmp/lucene/_32.fdx (Too many open files).

lsof -p says that there are many open file handles to the
same index file name, all but the last with a (deleted) marker.

I think I close everything properly.

Here's the code for the test case which reproduces the issue:

Directory ldir = new SimpleFSDirectory(new File("/tmp/lucene"));

IndexWriter writer = new IndexWriter(ldir, new StandardAnalyzer(Version.LUCENE_30), IndexWriter.MaxFieldLength.LIMITED);
IndexReader reader = IndexReader.open(ldir);
                
IndexSearcher searcher = new IndexSearcher(reader);

for (int i = 0; i < 1000; i++) {
        Document doc = new Document();
        doc.add(new Field("uri", "http://example.org/";, Field.Store.YES, 
Field.Index.NO));
        writer.addDocument(doc);
        writer.commit();
                        
        reader.reopen();
        searcher.close();
        searcher = new IndexSearcher(reader);
                        
        // do something here
                        
        Term term = new Term("uri", "http://example.org/";);
        writer.deleteDocuments(term);
        writer.commit();
}

Any idea what's going wrong?

Cheers,
Andreas.

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

Reply via email to