public T GetItem <T>(string indexName, FilterCondition filter, List <string> columns = null) { PageCondition page = new PageCondition(1, 1); string body = FilterToQueryString(indexName, filter, ref page); if (body == null) { return(default(T)); } StringResponse res = conn.LowLevel.Search <StringResponse>(PostData.String(body)); if (!res.Success) { return(default(T)); } ELSearchResponse <T> sr = JsonConvert.DeserializeObject <ELSearchResponse <T> >(res.Body); if (sr == null || sr.hits.total.value == 0) { return(default(T)); } T data = sr.hits.hits[0]._source; return(data); }
public List <T> GetItemList <T>(string indexName, FilterCondition filter, ref PageCondition page, List <string> columns = null) { string body = FilterToQueryString(indexName, filter, ref page); StringResponse res = conn.LowLevel.Search <StringResponse>(PostData.String(body)); if (!res.Success) { return(null); } ELSearchResponse <T> sr = JsonConvert.DeserializeObject <ELSearchResponse <T> >(res.Body); if (sr == null) { return(null); } List <T> data = sr.hits.hits.ConvertAll(d => d._source); page.Total = sr.hits.total.value; return(data); }