/// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="change">被修改的实体</param>
 public LuceneIndexChangeset(LuceneIndexChange change)
 {
     Entries = new List <LuceneIndexChange>
     {
         change
     };
 }
        ///// <summary>
        ///// 初始化索引库
        ///// </summary>
        ///// <param name="options"></param>
        //private void InitializeLucene(LuceneIndexerOptions options)
        //{
        //    if (_directory == null)
        //    {
        //        _directory = FSDirectory.Open(options.Path);
        //    }

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

        /// <summary>
        /// 检查数据库上下文更改,并返回LuceneIndexChanges类型的集合
        /// </summary>
        /// <returns> LuceneIndexChangeset  - 转换为LuceneIndexChanges类型的实体更改集合</returns>
        private LuceneIndexChangeset GetChangeset()
        {
            LuceneIndexChangeset changes = new LuceneIndexChangeset();

            foreach (var entity in Context.ChangeTracker.Entries().Where(x => x.State != EntityState.Unchanged))
            {
                Type entityType = entity.Entity.GetType();
                bool implementsILuceneIndexable = typeof(ILuceneIndexable).IsAssignableFrom(entityType);
                if (implementsILuceneIndexable)
                {
                    MethodInfo method = entityType.GetMethod("ToDocument");
                    if (method != null)
                    {
                        LuceneIndexChange change = new LuceneIndexChange(entity.Entity as ILuceneIndexable);

                        switch (entity.State)
                        {
                        case EntityState.Added:
                            change.State = LuceneIndexState.Added;
                            break;

                        case EntityState.Deleted:
                            change.State = LuceneIndexState.Removed;
                            break;

                        case EntityState.Modified:
                            change.State = LuceneIndexState.Updated;
                            break;

                        default:
                            change.State = LuceneIndexState.Unchanged;
                            break;
                        }
                        changes.Entries.Add(change);
                    }
                }
            }

            return(changes);
        }
        /// <summary>
        /// 更新索引
        /// </summary>
        /// <param name="change">实体</param>
        public void Update(LuceneIndexChange change)
        {
            var changeset = new LuceneIndexChangeset(change);

            Update(changeset);
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="change">被修改的实体</param>
 public LuceneIndexChangeset(LuceneIndexChange change) => Entries = new List <LuceneIndexChange>