Пример #1
0
        public void Initialize(LuceneIndexerOptions indexerOptions, CTX context, bool overrideIfExists = false)
        {
            if (isInitialized == false || overrideIfExists == true)
            {
                initializeLucene(indexerOptions);
            }

            Context          = context;
            contextInterface = Context as IDbContext;
        }
Пример #2
0
        /// <summary>
        /// Initialize Lucene
        /// Sets up the directory, analyzer, indexer and searcher
        /// </summary>
        /// <param name="options"></param>
        private void initializeLucene(LuceneIndexerOptions options)
        {
            // create the directory
            if (options.UseRamDirectory == true)
            {
                directory = new RAMDirectory();
            }
            else
            {
                if (directory == null)
                {
                    directory = FSDirectory.Open(options.Path);
                }
            }

            // create the analyzer
            analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30);

            // create the indexer
            indexer = new LuceneIndexer(directory, analyzer, options.MaximumFieldLength);

            // create the searcher
            searcher = new LuceneIndexSearcher(directory, analyzer);
        }