lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cocula Remi" <rcoc...@sopragroup.com>
Subject RE: closing an IndexSearcher
Date Thu, 20 Jan 2005 11:43:52 GMT

Complementary to my prvious mail I noticed strange behaviour of IndexSearcher.close().
Here is a code that does not work : the new IndexWriter() statement throws "java.io.IOException:
Cannot delete _3.cfs" as if the Index searcher's underlying IndexReader where not closed.
 

			IndexSearcher searcher = new IndexSearcher("c:\\tmp\\index");
			searcher = new IndexSearcher("c:\\tmp\\index");
			searcher.close();

			writer = new IndexWriter("c:\\tmp\\index",ana,true);
			doc = new Document();
			doc.add(Field.Text("text","toto li toto"));
			writer.addDocument(doc);
			writer.close();

And now here is a code that works : the only differance with the previous one is the QueryParser
call before new IndexWriter. The QueryParser .parse statement seems to close the IndexReader
but I really can't figure how.
 
			IndexSearcher searcher = new IndexSearcher("c:\\tmp\\index");
			searcher = new IndexSearcher("c:\\tmp\\index");
			searcher.close();

			Query query = QueryParser.parse("toto","text",ana);			

			writer = new IndexWriter("c:\\tmp\\index",ana,true);
			doc = new Document();
			doc.add(Field.Text("text","toto li toto"));
			writer.addDocument(doc);
			writer.close();


Note : I use Lucene 1.4 Final

Does it seem to be a bug ? 

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


Mime
View raw message