You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by wolvernie88 <mw...@gmail.com> on 2008/05/09 17:38:43 UTC
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
Re: Is this the right way to use Lucene in multithread env?
Posted by wolvernie88 <mw...@gmail.com>.
Hi,
I am creating a new indexWriter to optimize the directory.
I will try using FSDirectory later.
Otis Gospodnetic wrote:
>
> 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 <mw...@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
>
>
>
--
View this message in context: http://www.nabble.com/Is-this-the-right-way-to-use-Lucene-in-multithread-env--tp17150728p17152621.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