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 <fancye...@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? >