Exemple #1
0
 /// <summary>
 /// 搜索引擎
 /// </summary>
 /// <param name="indexerOptions">索引选项</param>
 /// <param name="context">数据库上下文</param>
 /// <param name="overrideIfExists">是否被覆盖</param>
 public SearchEngine(LuceneIndexerOptions indexerOptions, TContext context, IMemoryCache memoryCache, bool overrideIfExists = false)
 {
     Context      = context;
     _memoryCache = memoryCache;
     if (isInitialized == false || overrideIfExists)
     {
         InitializeLucene(indexerOptions);
         isInitialized = true;
     }
 }
Exemple #2
0
        /// <summary>
        /// 初始化索引库
        /// </summary>
        /// <param name="options"></param>
        private void InitializeLucene(LuceneIndexerOptions options)
        {
            if (_directory == null)
            {
                _directory = FSDirectory.Open(options.Path);
            }

            _analyzer = new JieBaAnalyzer(TokenizerMode.Search);
            _indexer  = new LuceneIndexer(_directory, _analyzer);
            _searcher = new LuceneIndexSearcher(_directory, _analyzer, _memoryCache);
        }