private IndexWriter GetWriter(int siteId, Lucene.Net.Store.Directory indexDirectory) { IndexWriter indexWriter = null; LuceneSettingsProvider provider = LuceneSettingsManager.Providers[IndexHelper.GetSiteProviderName(siteId)]; if (provider == null) { log.Error("LuceneSettingsProvider could not be obtained"); return(null); } Analyzer analyzer = provider.GetAnalyzer(); if (!IndexReader.IndexExists(indexDirectory)) { try { indexWriter = new IndexWriter(indexDirectory, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED); } catch (System.IO.IOException ex) { log.Error(ex); try { indexWriter = new IndexWriter(indexDirectory, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED); } catch (System.IO.FileNotFoundException ex2) { log.Error(ex2); } } } else { try { indexWriter = new IndexWriter(indexDirectory, analyzer, false, IndexWriter.MaxFieldLength.UNLIMITED); } catch (System.IO.FileNotFoundException ex2) { log.Error(ex2); } } return(indexWriter); }
private static void Initialize() { //try //{ LuceneSettingsConfiguration config = LuceneSettingsConfiguration.GetConfig(); if ( (config.DefaultProvider == null) || (config.Providers == null) || (config.Providers.Count < 1) ) { throw new ProviderException("You must specify a valid default provider."); } providerCollection = new LuceneSettingsProviderCollection(); ProvidersHelper.InstantiateProviders( config.Providers, providerCollection, typeof(LuceneSettingsProvider)); providerCollection.SetReadOnly(); defaultProvider = providerCollection[config.DefaultProvider]; //} //catch (Exception ex) //{ // initializationException = ex; // isInitialized = true; // throw ex; //} isInitialized = true; }
public void CopyTo(LuceneSettingsProvider[] array, int index) { base.CopyTo(array, index); }