lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Is this the right way to use Lucene in multithread env?
Date Fri, 09 May 2008 17:04:45 GMT
Hi,

No need to close parse and it is good to use the same searcher.
I don't understand why you have that IndexWriter there if you are searching...

Also, you may not benefit from explicit loading of the index into RAM.  Try without it first.


Otis
--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch


----- Original Message ----
> From: wolvernie88 <mwang.zheng@gmail.com>
> To: java-user@lucene.apache.org
> Sent: Friday, May 9, 2008 11:38:43 AM
> Subject: Is this the right way to use Lucene in multithread env?
> 
> 
> Hi,
> 
> 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
> do
> 
>                 newIndexDirectory = new RAMDirectory(fsDirectory);
>             IndexWriter newWriter = new IndexWriter(newIndexDirectory, new
> StandardAnalyzer(), true);
>             newWriter.optimize();
>             newWriter.close();
>                 searcher = new IndexSearcher(newIndexDirectory );
> 
> For every new search, I do
> 
>             QueryParser parser = new QueryParser("field1", new 
> StandardAnalyzer());
>             Query query = parser.parse(queryString);
>             Hits hits = searcher.search(query);
> 
> 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
> time.
> 
> Thanks much.
> -- 
> View this message in context: 
> http://www.nabble.com/Is-this-the-right-way-to-use-Lucene-in-multithread-env--tp17150728p17150728.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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


Mime
View raw message