SpellChecker.Net.Search.Spell.SpellChecker.SetSpellIndex C# (CSharp) Method

SetSpellIndex() public method

Use a different index as the spell checker index or re-open the existing index if spellIndex is the same value as given in the constructor.
public SetSpellIndex ( Lucene.Net.Store.Directory spellIndexDir ) : void
spellIndexDir Lucene.Net.Store.Directory spellIndexDir the spell directory to use
return void
        virtual public void SetSpellIndex(Directory spellIndexDir)
        {
            // this could be the same directory as the current spellIndex
            // modifications to the directory should be synchronized 
            lock (modifyCurrentIndexLock)
            {
                EnsureOpen();
                if (!IndexReader.IndexExists(spellIndexDir))
                {
                    var writer = new IndexWriter(spellIndexDir, null, true,
                        IndexWriter.MaxFieldLength.UNLIMITED);
                    writer.Close();
                }
                SwapSearcher(spellIndexDir);
            }
        }