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!"); } }
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!"); } }
public ElasticSearchRepository() { NestClientProvider.GetClient(); }