/// <summary> /// HEAD /employee/employee/1 /// </summary> public void DocumentExists() { var response = client.DocumentExists<employee>("1一狮"); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// PUT /employee/employee/1/_create /// </summary> public void CreateDoc() { var e = new employee() { about = "这是about", age = 26, first_name = "陈", interests = new List<string> { "篮球" }, last_name = "小明 小红", dto = new employeedto { Id = Guid.NewGuid() } }; var response = client.Create<employee>(e, x => x.Id(e.last_name)); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// PUT /employee/employee1?op_type=create /// </summary> public void IndexDocOptypeCreate() { var e = new employee() { about = "这是about", age = 26, first_name = "陈", interests = new List<string> { "篮球" }, last_name = "小明 小红", dto = new employeedto { Id = Guid.NewGuid() } }; var response = client.Index<employee>(e, x => x.Id(e.last_name).OpType(OpType.Create)); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// DELETE /employee/employee/2 /// </summary> public void Delete() { var response = client.Delete<employee>("一狮2"); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 乐观并发控制 /// PUT /employee/employee/1?version=5 /// </summary> public void IndexDocVersion() { var e = new employee() { about = "这是about", age = 26, first_name = "陈", interests = new List<string> { "篮球" }, last_name = "一狮", dto = new employeedto { Id = Guid.NewGuid() } }; var response = client.Index<employee>(e, x => x.Id(e.last_name).Version(1)); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 乐观并发控制external /// PUT /employee/employee/1?version=5&version_type=external /// </summary> public void IndexDocVersionExternal() { var e = new employee() { about = "这是about", age = 26, first_name = "陈", interests = new List<string> { "篮球" }, last_name = "一狮", dto = new employeedto { Id = Guid.NewGuid() } }; var response = client.Index<employee>(e, x => x.Id(e.last_name).Version(5).VersionType(VersionType.External)); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 更新 /// POST /employee/employee/1/_update /// </summary> public void Update() { var response = client.Update<employee>("一狮", x => x.Doc(new employee() { height = 180 })); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 更新 /// POST /employee/employee/1/_update?retry_on_conflict=3 /// </summary> public void UpdateRetryOnConflict() { var response = client.Update<employee>("一狮", x => x.Doc(new employee() { height = 180 }).RetryOnConflict(3)); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 获取多个doc /// POST /_mget /// </summary> public void Mget() { var response = client.MultiGet(x => x.Type("employee").Get<employee>(g => g.Id("一狮")).Type("employee").Get<employee>(gg => gg.Id("小明 小红"))); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 获取多个doc /// POST /employee/employee/_mget /// </summary> public void Mget2() { var response = client.MultiGet(x => x.Index("employee").Type("employee").Get<employee>(g => g.Id("一狮")).Get<employee>(gg => gg.Id("小明 小红"))); Console.WriteLine(JsonConvert.SerializeObject(response)); } /// <summary> /// 批量操作 /// POST /_bulk /// </summary> public void Bulk() { var response = client.Bulk(x => x.Create<employee>(e => e.Document(new employee() { last_name = "Bulk1" })).Create<employee>(e => e.Document(new employee() { last_name = "Bulk2" }))); Console.WriteLine(JsonConvert.SerializeObject(response)); }