public ResultES GetContent(string _id) { var client = CreateElasticClient(); var request = client.Get <Content>(_id).Source; ResultES result = new ResultES(); if (request == null) { result.ResponseCode = (int)HttpStatusCode.NotFound; } else { result.ResponseCode = (int)HttpStatusCode.OK; result.Data = request; } return(result); }
public ResultES SearchAll(string search) { var client = CreateElasticClient(); //Content //var content = client.Search<Content>(s => s // .AllTypes() // .Query(q => q // .Bool(b => b // .Must(m => m // .QueryString(qs => qs // .DefaultField("_all") // .Query(search)))))); //var content = client.Search<Content>(s => s // .AllTypes() // .Query(q => q // .QueryString(qs => qs.Query(search) // ))); var content = client.Search <Content>(s => s .Query(q => q .QueryString(qs => qs .Query(search) .Fields(fs => fs .Fields(f1 => f1.content_name))))); ResultES result = new ResultES(); if (content.Hits.Count() == 0) { result.ResponseCode = (int)HttpStatusCode.NotFound; } else { result.ResponseCode = (int)HttpStatusCode.OK; result.Data = content.Hits.ToList(); } return(result); }