lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wolvernie88 <>
Subject Is this the right way to use Lucene in multithread env?
Date Fri, 09 May 2008 15:38:43 GMT


Here is what I am using Lucene.

I build the index (from different data source) during midnight. I build a
FSDirectory. Then I load it into RAMDirectory for the best performance. When
I built it, I called IndexWriter.optimize() once. 

Once the index is built, I will never update it.

I have static variable defined as IndexSearcher. Once I load RAMDirectory, I

		        newIndexDirectory = new RAMDirectory(fsDirectory);
			IndexWriter newWriter = new IndexWriter(newIndexDirectory, new
StandardAnalyzer(), true);
		        searcher = new IndexSearcher(newIndexDirectory );

For every new search, I do

			QueryParser parser = new QueryParser("field1", new StandardAnalyzer());
			Query query = parser.parse(queryString);
			Hits hits =;

Is this the right way? Do I need to close parse, query or hits?

As I have only one IndexSearcher, will it cause any problem?

I found  using the same query does not always give me the same response

Thanks much.
View this message in context:
Sent from the Lucene - Java Users mailing list archive at

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

View raw message