public IActionResult GetValues() { Value tempPerson = null; var values = ConnectionToES.ESClinet().Search <Value>(s => s .Index("people") .Type("person") .From(0) .Size(1000) .Query(q => q.MatchAll())); var persons = values.Hits.ToList(); List <Value> personList = new List <Value>(); foreach (var item in persons) { tempPerson = new Value { ID = item.Source.ID, Name = item.Source.Name }; personList.Add(tempPerson); } return(Ok(personList)); }
public IActionResult DeleteAsync(int id) { var response = ConnectionToES.ESClinet().Delete <Value>(id, d => d .Index("people") .Type("person")); return(Ok()); }
public void Post([FromBody] Value per) { Value person = new Value { ID = per.ID, Name = per.Name }; var response = ConnectionToES.ESClinet().IndexAsync <Value>(per, i => i .Index("people") .Type("person") ); }
public IActionResult GetValue(int id) { Value tempPerson = null; var response = ConnectionToES.ESClinet().Search <Value>(s => s .Index("people") .Type("person") .From(0) .Size(1000) .Query(q => q.Term(fld => fld.ID, id))); if (response != null) { var person = response.Hits.FirstOrDefault(); tempPerson = new Value { ID = person.Source.ID, Name = person.Source.Name }; } return(Ok(tempPerson)); }