/// <summary> /// Index a document /// </summary> /// <typeparam name="T"></typeparam> /// <param name="indexName"></param> /// <param name="document"></param> /// <returns></returns> public virtual async Task <IndexResponse> IndexAsync <T>(string indexName, T document) where T : class { var response = await GetElasticClient().IndexAsync(document, i => i.Index(indexName).Type <T>()); var indexResponse = new IndexResponse { IsValid = response.IsValid, StatusMessage = response.DebugInformation, Exception = response.OriginalException }; return(indexResponse); }
/// <summary> /// Index document collection /// </summary> /// <typeparam name="T"></typeparam> /// <param name="indexName"></param> /// <param name="documents"></param> /// <returns></returns> public virtual async Task <IndexResponse> BulkIndexAsync <T>(string indexName, IEnumerable <T> documents) where T : class { var response = await GetElasticClient().IndexManyAsync(documents, indexName); var indexResponse = new IndexResponse { IsValid = response.IsValid, StatusMessage = response.DebugInformation, Exception = response.OriginalException }; return(indexResponse); }