lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Spencer, Dave" <d...@lumos.com>
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().

java.io.IOException: Index locked for write:
Lock@C:\tmp\luc\locktest\write.lock

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 = IndexReader.open( 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
statements.
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
documents.




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


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

Sometimes I am getting the following exception:
java.io.IOException: Index locked for write:
Lock@D:\RevealCS\Search\Data\reports\write.lock
	at org.apache.lucene.index.IndexReader.delete(Unknown Source)
	at org.apache.lucene.index.IndexReader.delete(Unknown Source)
	at
revsearch.RevSearch$DeleteWatcherThread.checkAction(RevSearch.java:1455)
	at revsearch.RevSearch$WatcherThread.run(RevSearch.java:250)

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

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

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



--
To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message