lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cocula Remi" <rcoc...@sopragroup.com>
Subject closing an IndexSearcher
Date Wed, 19 Jan 2005 17:14:56 GMT

Hi ,

I remarked that after closing an IndexSearcher, queries on this Seacher will still run.
My question is : why not always closing an IndexSearcher ?
In my case I need to close all indexsearchers when I want to rebuild the index.



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

Query query = QueryParser.parse("toto","text",ana);
			
			
Hits hits = searcher.search(query);
System.out.println(hits.length());
for (int i=0;i<hits.length();i++)
{
	Document d = hits.doc(i);
	System.out.println(d.get("text"));
}
System.out.println("fin");
---------------------------------------------------

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message