From java-user-return-29089-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Mon Jul 09 08:36:03 2007 Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 92725 invoked from network); 9 Jul 2007 08:36:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Jul 2007 08:36:02 -0000 Received: (qmail 93363 invoked by uid 500); 9 Jul 2007 08:35:58 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 92900 invoked by uid 500); 9 Jul 2007 08:35:57 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 92888 invoked by uid 99); 9 Jul 2007 08:35:57 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jul 2007 01:35:57 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=UNPARSEABLE_RELAY X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: local policy) Received: from [219.118.71.125] (HELO mail.kai.ad.jp) (219.118.71.125) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jul 2007 01:35:53 -0700 Received: from mail.kai.ad.jp by mail.kai.ad.jp via smtpd (for herse.apache.org [140.211.11.133]) with ESMTP; Mon, 9 Jul 2007 17:35:33 +0900 Received: from linkclub-staff.com [219.118.70.66] by mail.kai.ad.jp (SMTPD32-7.07) id A3501BBD006E; Mon, 09 Jul 2007 17:35:28 +0900 From: anson To: java-user@lucene.apache.org Subject: RE: Should the IndexSearcher be closed after very search completed Date: Mon, 09 Jul 2007 17:34:25 +0900 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: HidemaruMail 4.59 (WinNT,501) In-Reply-To: References: Message-Id: <20C7C203F4DD5Fanson@linkclub-staff.com> X-Virus-Checked: Checked by ClamAV on apache.org 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