【发布时间】:2016-11-09 16:41:45
【问题描述】:
我对 ES 很陌生。我使用https://github.com/dariusk/corpora/blob/master/data/humans/us_presidents.json 作为学习集。
起初我在 Kibana 的开发工具选项卡中输入了这个:
POST /presidents/president/1
{ "bo" :
{
"website":"",
"startdate":"2009-01-20",
"role_type_label":"President",
"enddate":"2013-01-20",
"description":"President",
"district":null,
"phone":null,
"title":"President",
"congress_numbers":[
111,
112,
113
],
"title_long":"President",
"current":false,
"person":{
"name":"President Barack Obama [D]",
"firstname":"Barack",
"twitterid":null,
"middlename":"",
"gender":"male",
"bioguideid":"O000167",
"namemod":"",
"birthday":"1961-08-04",
"link":"https://www.govtrack.us/congress/members/barack_obama/400629",
"youtubeid":null,
"sortname":"Obama, Barack (President) [D]",
"lastname":"Obama",
"gender_label":"Male",
"osid":"N00009638",
"pvsid":"9490",
"nickname":"",
"id":400629,
"cspanid":null
}
...
}
}
然后我意识到,如果我想添加更多关于个别总统的数据,我宁愿这样做:
POST /presidents/president/1
{
"website":"",
"startdate":"2009-01-20",
"role_type_label":"President",
"enddate":"2013-01-20",
"description":"President",
"district":null,
"phone":null,
"title":"President",
"congress_numbers":[
111,
112,
113
],
"title_long":"President",
"current":false,
"person":{
"name":"President Barack Obama [D]",
"firstname":"Barack",
"twitterid":null,
"middlename":"",
"gender":"male",
"bioguideid":"O000167",
"namemod":"",
"birthday":"1961-08-04",
"link":"https://www.govtrack.us/congress/members/barack_obama/400629",
"youtubeid":null,
"sortname":"Obama, Barack (President) [D]",
"lastname":"Obama",
"gender_label":"Male",
"osid":"N00009638",
"pvsid":"9490",
"nickname":"",
"id":400629,
"cspanid":null
}
}
好的,所以 ES 接受了更新。
但是现在,当我转到 Kibana 中的管理/索引模式时,我将 person.lastname 和 bo.person.lastname 都视为字段。
为什么保留前一个字段? ES 保留更新文档中不再存在的字段是否正常?
显然,除了特别有趣的内容之外,请不要对今天的选举结果进行调侃。
【问题讨论】:
标签: elasticsearch kibana