--- On Sat, 1/8/11, Andreas Harth <andr...@harth.org> wrote: > From: Andreas Harth <andr...@harth.org> > Subject: Frequent updates lead to "Too many open files" > To: java-user@lucene.apache.org > Date: Saturday, January 8, 2011, 6:30 PM > 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?
Doing commit operation at the end of the loop can solve your problem. It is not a good idea to commit after every single addition. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org