public void Index(TestModel5 data, string indexName) { //写入数据,指定索引 _client.Index(data, s => s.Index(indexName)); //指定索引、类型 //_client.Index(data, s => s.Index(indexName).Type("TestModel5")); }
public void Update(string indexName, int id, TestModel5 model) { //完整更新 DocumentPath <TestModel5> path = new DocumentPath <TestModel5>(id); var response = _client.Update(path, (p) => p.Index(indexName).Doc(model)); //或 //IUpdateRequest<TestModel5, TestModel5> request = new UpdateRequest<TestModel5, TestModel5>(path) //{ // Doc = new TestModel5() // { // Name = "test4update........" // } //}; //response = _client.Update<TestModel5, TestModel5>(request); //局部更新 //IUpdateRequest<TestModel5, TestModel5P> request1 = new UpdateRequest<TestModel5, TestModel5P>(path) //{ // Doc = new TestModel5P() // { // Name = "test4update........" // } //}; //response = _client.Update(request1); ////或 //IUpdateRequest<TestModel5, object> request2 = new UpdateRequest<TestModel5, object>(path) //{ // Doc = new // { // Name = "test4update........" // } //}; //response = _client.Update(request2); }