示例#1
0
 public async Task RemoveData(params T[] data)
 {
     if (Init)
     {
         foreach (var item in data)
         {
             await NestClientProvider.GetClient().DeleteAsync <T>(item, i => i.Index(IndexName));
         }
     }
     else
     {
         throw new Exception("没有初始化ElasticSearchRepository!");
     }
 }
示例#2
0
        public async Task <List <T> > SearchData()
        {
            if (Init)
            {
                searchParams.Index(IndexName).Sort(s => sortQueries).Query(q => q.Bool(b => b.Must(mustQueries).MustNot(mustnotQueries).Filter(rangeQueries)));
                search = (s) => searchParams;
                var response = await NestClientProvider.GetClient().SearchAsync(search);

                if (response.ApiCall.Success)
                {
                    return(response.Documents.ToList());
                }
                throw new InfrastructureException("数据访问失败!");
            }
            else
            {
                throw new Exception("没有初始化ElasticSearchRepository!");
            }
        }
示例#3
0
 public ElasticSearchRepository()
 {
     NestClientProvider.GetClient();
 }