lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edwin Tang <emtt...@yahoo.com>
Subject Questions related to closing the searcher
Date Fri, 24 Sep 2004 17:45:18 GMT
Thanks for the tip. However, since the index is
constantly updated, I won't have to check whether it
has changed. I'm just puzzled as to why I'm running
out of memory when I'm closing the searcher, setting
it to null, running the garbage collector, then
getting a new searcher.

Ed

--- amordo@infosciences.com wrote:

> 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/IndexReader.html#getCurrentVersion(java.lang.String)
> 
> Aviran
> 
> -----Original Message-----
> From: Edwin Tang [mailto:emttang@yahoo.com] 
> 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 == null || parser == null) {
>             analyzer = new
CIAnalyzer(utility.sStopWordsFile);
>             try {
>                 vector = 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 = (IndexSearcher[])
vector.toArray(new IndexSearcher[vector.size()]);
>                 searcher = new
ParallelMultiSearcher(searchers);
>                 parser = new QueryParser("body",
analyzer);
>                 iReturn = 0;
>             } catch (IOException ioe) {
>                 logger.error("Error creating
searcher", ioe);
>                 iReturn = -1;
>             } catch (Exception e) {
>                 logger.error("Unexpected error while
creating searcher", e);
>                 iReturn = -1;
>             }
>         } else
>             iReturn = 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
> 
> 
> 		
> __________________________________
> 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


		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message