Пример #1
0
 /// <summary>
 /// 批量保存
 /// </summary>
 /// <param name="entitys">参数</param>
 public virtual void Save(List <T> entitys)
 {
     if (entitys == null || entitys.Count == 0)
     {
         return;
     }
     EsClient.IndexMany(entitys, CurrentIndex);
     EsClient.Refresh(CurrentIndex);
 }
Пример #2
0
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids">Id</param>
        public virtual void Delete(string[] ids)
        {
            var esResult = EsClient.MultiGet(m => m.GetMany <T>(ids).Index(CurrentIndex));

            if (esResult.Documents.Count <= 0)
            {
                return;
            }
            foreach (var esResultDocument in esResult.Documents)
            {
                if (!esResultDocument.Found)
                {
                    continue;
                }
                EsClient.Delete <T>(esResultDocument.Id, f => f.Index(CurrentIndex));
            }
            EsClient.Refresh(CurrentIndex);
        }