lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anson <an...@linkclub-staff.com>
Subject RE: Should the IndexSearcher be closed after very search completed
Date Mon, 09 Jul 2007 08:34:25 GMT
Hi Ard,

Thanks for your reply, well, I think I have done right.


>Closing the IndexSearcher is best only after a deleteDocuments with a 
>reader or changes with a writer.
>
>For performance reasons, it is better to not close the IndexSearcher if not
> needed
>
>Regarsd Ard 
>
>> 
>> 
>> sorry, the subject should be "Should the IndexSearcher be 
>> closed after 
>> every search completed"
>> ~~~~~
>> >Hi,
>> >
>> >Should the IndexSearcher instance be closed after very 
>> search completed.
>> >
>> >I wrote a sample, but I have not closed the singleton instatnce of 
>> >IndexSearcher unless IndexReader#isCurrent() return false.
>> >
>> >Now the sample runs well, but I saw almost other samples 
>> would close the  
>> >IndexSearcher instance on the end of very search.
>> >
>> >Should I do it like them?
>> >
>> >By the way, I use the constructor IndexSearcher(Directory 
>> directory), so  
>> >should I call the method IndexSearcher.close()?
>> >
>> >
>> >------------------------------------
>> >the Code sample:
>> >------------------------------------
>> >public IndexSearcher getIndexSearcher() throws IOException {
>> >		
>> >	if (this.indexSearcher == null) {
>> >		return new IndexSearcher(getIndexDirectory());
>> >	} else {
>> >		IndexReader ir = indexSearcher.getIndexReader();
>> >		if(!ir.isCurrent()){
>> >			this.indexSearcher.close();
>> >			this.indexSearcher=new IndexSearcher
>> >(getIndexDirectory());
>> >			ir=indexSearcher.getIndexReader();
>> >			if(ir.hasDeletions()){
>> >				if (this.indexWriter != null) {
>> >					this.indexWriter.optimize();
>> >				}	
>> >			}
>> >		}
>> >		return this.indexSearcher;
>> >	}
>> >}
>> >
>> >
>> >Best regards
>> >Anson
>> >
>> >---------------------------------------------------------------------
>> >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
>> 
>> 
>
>---------------------------------------------------------------------
>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