Any unclosed and unused searcher that doesn't get closed will simply get 
garbage collected when its time is up and when the GC gets to it.

Are you seeing problems with the spellchecker?   

Otis

--
Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch

----- Original Message ----
From: sujithq <[EMAIL PROTECTED]>
To: java-dev@lucene.apache.org
Sent: Thursday, December 6, 2007 10:13:54 AM
Subject: SpellChecker in 2.2.0


Hi,

Is there any reason why property searcher is never closed?

This is code for the constructor
  /**
   * Use the given directory as a spell checker index. The directory
   * is created if it doesn't exist yet.
   * 
   * @param spellIndex
   * @throws IOException
   */
  public SpellChecker(Directory spellIndex) throws IOException {
    this.setSpellIndex(spellIndex);
  }

  /**
   * Use a different index as the spell checker index or re-open
   * the existing index if <code>spellIndex</code> is the same value
   * as given in the constructor.
   * 
   * @param spellIndex
   * @throws IOException
   */
  public void setSpellIndex(Directory spellIndex) throws IOException {
    this.spellIndex = spellIndex;
    if (!IndexReader.indexExists(spellIndex)) {
        IndexWriter writer = new IndexWriter(spellIndex, null, true);
        writer.close();
    }
    // close the old searcher, if there was one
    if (searcher != null) {
      searcher.close();
    }
    searcher = new IndexSearcher(this.spellIndex);
  }


Sujith
-- 
View this message in context:
 http://www.nabble.com/SpellChecker-in-2.2.0-tf4956508.html#a14193891
Sent from the Lucene - Java Developer mailing list archive at
 Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to