Return-Path: Delivered-To: apmail-jakarta-lucene-user-archive@www.apache.org Received: (qmail 9501 invoked from network); 23 Sep 2004 14:17:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 23 Sep 2004 14:17:39 -0000 Received: (qmail 24349 invoked by uid 500); 23 Sep 2004 14:17:26 -0000 Delivered-To: apmail-jakarta-lucene-user-archive@jakarta.apache.org Received: (qmail 24149 invoked by uid 500); 23 Sep 2004 14:17:25 -0000 Mailing-List: contact lucene-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Lucene Users List" Reply-To: "Lucene Users List" Delivered-To: mailing list lucene-user@jakarta.apache.org Received: (qmail 24135 invoked by uid 99); 23 Sep 2004 14:17:25 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from [141.156.69.115] (HELO mail.infosciences.com) (141.156.69.115) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 23 Sep 2004 07:17:23 -0700 Received: from Aviran (unknown [141.156.69.109]) by mail.infosciences.com (Postfix) with ESMTP id 9F919118308 for ; Thu, 23 Sep 2004 10:19:35 -0400 (EDT) From: "Aviran" To: "'Lucene Users List'" Subject: RE: Questions related to closing the searcher Date: Thu, 23 Sep 2004 10:15:22 -0400 Message-ID: <002c01c4a177$c3ad6f40$6a00a8c0@Aviran> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.6626 In-Reply-To: <20040922153750.80116.qmail@web53008.mail.yahoo.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 Importance: Normal X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N The best way is to use IndexReader's getCurrentVersion() method to check whether the index has changed. If it has, just get a new Searcher http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/index/IndexRe= ade r.html#getCurrentVersion(java.lang.String) Aviran -----Original Message----- From: Edwin Tang [mailto:emttang@yahoo.com]=20 Sent: Wednesday, September 22, 2004 11:38 AM To: lucene-user@jakarta.apache.org Subject: Fwd: Questions related to closing the searcher Hello, In my testing, it seems like if the searcher (in my case ParallelMultiSearcher) is not closed, the searcher will not pick up any new data that has been added to the index since it was opened. I'm wondering if this is a correct statement. Assuming the above is true, I went about closing the searcher with searcher.close(), then setting both the searcher and QueryParser to null, then did a System.gc(). The application will sleep for a set period of time, then resumes to process another batch of queries against the index. When the application resumes, the following method is ran: /** * Creates a {@link ParallelMultiSearcher} and {@link QueryParser} if they * do not already exist. * * @return 0 if successful or the objects already exist; -1 if failed. */ private int getSearcher() { Analyzer analyzer; IndexSearcher[] searchers; int iReturn; Vector vector; if (logger.isDebugEnabled()) logger.debug("Entering getSearcher()"); if (searcher =3D=3D null || parser =3D=3D null) { analyzer =3D new CIAnalyzer(utility.sStopWordsFile); try { vector =3D new Vector(); if (utility.bSearchAMX) vector.add(new IndexSearcher(utility.amxIndexDir)); if (utility.bSearchCOMTEX) vector.add(new = IndexSearcher(utility.comtexIndexDir)); if (utility.bSearchDJNW) vector.add(new IndexSearcher(utility.djnwIndexDir)); if (utility.bSearchMoreover) vector.add(new = IndexSearcher(utility.moreoverIndexDir)); searchers =3D (IndexSearcher[]) vector.toArray(new IndexSearcher[vector.size()]); searcher =3D new ParallelMultiSearcher(searchers); parser =3D new QueryParser("body", analyzer); iReturn =3D 0; } catch (IOException ioe) { logger.error("Error creating searcher", ioe); iReturn =3D -1; } catch (Exception e) { logger.error("Unexpected error while creating searcher", e); iReturn =3D -1; } } else iReturn =3D 0; if (logger.isDebugEnabled()) logger.debug("Exitng getSearcher() with " + iReturn); return iReturn; } // End method getSearcher() This seems to get me around the problem where the searcher was not picking up new data from the index. However, I would run out of memory after 8 iterations of the application processing a batch query, sleeping, process another batch query, sleep, etc. I'm probably missing something completely obvious, but I'm just not seeing it. Can someone please tell me what I'm doing wrong? Thanks, Ed =09 __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: lucene-user-help@jakarta.apache.org