BetterCMS.Module.LuceneSearch.Services.IndexerService.DefaultIndexerService.Initialize C# (CSharp) 메소드

Initialize() 개인적인 메소드

private Initialize ( ) : bool
리턴 bool
        private bool Initialize()
        {
            if (initialized)
            {
                return true;
            }

            if (failedToInitialize)
            {
                return false;
            }

            var fileSystemPath = cmsConfiguration.Search.GetValue(LuceneSearchConstants.ConfigurationKeys.LuceneFileSystemDirectory);
            if (string.IsNullOrWhiteSpace(fileSystemPath))
            {
                Log.Error("Cannot Initialize Lucene indexer. Lucene file system path is not set.");
                failedToInitialize = true;

                return false;
            }
            directory = GetLuceneDirectory(fileSystemPath);
            index = FSDirectory.Open(directory);

            try
            {
                configurationExcludedNodeTypes = GetCollectionFromConfiguration(LuceneSearchConstants.ConfigurationKeys.LuceneExcludedNodes);
                configurationExcludedIds = GetCollectionFromConfiguration(LuceneSearchConstants.ConfigurationKeys.LuceneExcludedIds);
                configurationExcludedClasses = GetCollectionFromConfiguration(LuceneSearchConstants.ConfigurationKeys.LuceneExcludedClasses);
                configurationExcludedPages = GetCollectionFromConfiguration(LuceneSearchConstants.ConfigurationKeys.LuceneExcludedPages).Select(t => t.Split('#', '?').FirstOrDefault()).ToList();

                bool.TryParse(cmsConfiguration.Search.GetValue(LuceneSearchConstants.ConfigurationKeys.LuceneSearchForPartOfWordsPrefix), out searchForPartOfWords);

                bool disableStopWords;
                if (!bool.TryParse(cmsConfiguration.Search.GetValue(LuceneSearchConstants.ConfigurationKeys.LuceneDisableStopWords), out disableStopWords))
                {
                    disableStopWords = false;
                }
                if (disableStopWords)
                {
                    analyzer = new StandardAnalyzer(Version.LUCENE_30, new HashSet<string>());
                }
                else
                {
                    analyzer = new StandardAnalyzer(Version.LUCENE_30);
                }

                if (searchForPartOfWords)
                {
                    parser = new PartialWordTermQueryParser(Version.LUCENE_30, "content", analyzer);
                }
                else
                {
                    parser = new QueryParser(Version.LUCENE_30, "content", analyzer);
                }
                parser.AllowLeadingWildcard = true;

                if (!IndexReader.IndexExists(index))
                {
                    OpenWriter(true);
                    CloseWriter();
                }
            }
            catch (Exception exc)
            {
                Log.Error("Failed to initialize Lucene search engine.", exc);
                failedToInitialize = true;

                return false;
            }

            initialized = true;
            return true;
        }