lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spencer, Dave" <>
Subject RE: Deleting documents
Date Wed, 13 Mar 2002 02:13:47 GMT
I think I've come across the same problem.
If you have an indexer that adds docs and also deletes docs as it goes
(use case: it's updating
old docs or adding new ones) it seems that you always get
an exception like this thrown from IndexReader.delete(). Index locked for write:

I had code similar to the code below, and then modified
to explicitely use the same Directory, to no avail.
Approx code:

	Directory dir = FSDirectory.getDirectory( indexName, create);
	IndexWriter writer = new IndexWriter( dir, ..., create);
	IndexReader reader = dir);
	// now calls to writer.addDocument() work
	// if you call reader.delete(int) it fails

I've attached the full src below though it's a bit messy w/ trace
Should work fine as an isolation test case.
Uses windows dir names, sorry to Unix folk.

This fails against rc4 and also the latest build (0312).

I'm positive a few months ago this stuff worked fine.

If this is indeed a bug then I think the IndexReader and IndexWriter
should "know" they're
sharing a Directory, whereas now they don't seem to.

As a side note I've always found it strange that IndexReader was used to
delete entries. "reader" to me means read-only, thus I would have
expected IndexWriter to be the thing that is used to add/delete

-----Original Message-----
From: Aruna Raghavan []
Sent: Friday, March 08, 2002 10:40 AM
To: 'Lucene Users List'
Subject: Deleting documents

Is there anything wrong with the following code?
      try {
       m_lock.write(); // obtain a write lock on a RWLock
       IndexReader indexReader ="mypath");
       IndexSearcher indexSearcher = new IndexSearcher("mypath");
      // use the searcher to search for documents to be deleted
      // use the reader to do the deletes.
      catch(Throwable e)

Sometimes I am getting the following exception: Index locked for write:
	at org.apache.lucene.index.IndexReader.delete(Unknown Source)
	at org.apache.lucene.index.IndexReader.delete(Unknown Source)
	at revsearch.RevSearch$

This exception was not happening every time the code was run, it was

I suspect it is because I am using indexSearcher and indexWriter to open
myPath dir. I changed it such that indexSearcher uses the indexReader in

I am hoping that some one can shed some light on what went wrong,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message