lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: What will happen when one thread is closing a searcher while another is searching?
Date Tue, 06 Sep 2011 10:46:39 GMT
Closing a searcher while thread(s) is/are still using it is definitely
bad, so, this code looks spooky...

But: it possible something higher up (in Solr) is ensuring this code
runs exclusively?  I don't know enough about this part of Solr...

Mike McCandless

http://blog.mikemccandless.com

On Mon, Sep 5, 2011 at 10:43 PM, Li Li <fancyerii@gmail.com> wrote:
> hi all,
>     I am using spellcheck in solr 1.4. I found that spell check is not
> implemented as SolrCore. in SolrCore, it uses reference count to track
> current searcher. oldSearcher and newSearcher will both exist if oldSearcher
> is servicing some query. But in FileBasedSpellChecker
>
>  public void build(SolrCore core, SolrIndexSearcher searcher) {
>    try {
>      loadExternalFileDictionary(core.getSchema(),
> core.getResourceLoader());
>      spellChecker.clearIndex();
>      spellChecker.indexDictionary(dictionary);
>    } catch (IOException e) {
>      throw new RuntimeException(e);
>    }
>  }
>  public void clearIndex() throws IOException {
>    IndexWriter writer = new IndexWriter(spellIndex, null, true);
>    writer.close();
>
>    //close the old searcher
>    searcher.close();
>    searcher = new IndexSearcher(this.spellIndex);
>  }
>
>  it clear old Index and close current searcher. When other thread is doing
> search and searcher.close() is called, will it cause problem? Or
> searcher.close() has finished and new IndexSearch has not yet constructed.
> When other thread try to do search, will it also be problematic?
>

---------------------------------------------------------------------
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