Update child object in ElasticSearch using NEST -


i have elastic search document following structure:

{    "id": 123,    "name": "myname",    "skill": {          "skillid": 321,          "name": "skill name",          "description": "skill description"     }  } 

i have class maps document:

public class person {       public int id { get; set; }       public string name { get; set; }       public skill skill { get; set; } }  public class skill{       public int skillid { get; set; }       public string name { get; set; }       public string description { get; set; } } 

now want update skill description on elastic search:

var person = _client.get(.......) var newskill = new skill(); newskill.skillid = person.skill.skillid; newskill.description = "this new description"  var result = _client.update<person, skill>(u => u             .idfrom(person)             .doc(newskill)             .retryonconflict(3)             .refresh()         ); 

this code not update existing skill of person, instead, adds skill properties root of person.

so whats wrong here ?

you trying use elasticsearch if sql.

you need assign new skill person , update whole person object follow:

var person = _client.get(.......) var newskill = new skill(); newskill.name = "new skill"; newskill.description = "this new description"  person.skill = newskill;  var result = _client.update<person, person>(u => u             .idfrom(person)             .doc(person)             .retryonconflict(3)             .refresh()         ); 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -