我正在尝试使用 Loop 创建映射来处理嵌套字典。
我的映射表应该看起来像下面的值。
{
"mapping": {
"properties": {
"clusterName": {
"properties": {
"infoAddr": { "type": "string" },
"usedSpace": { "type": "string" },
"capacity": { "type": "int" },
"version": { "type": "string"},
"used": { "type": "int"},
"remaining": { "type" : "int"},
"volfails": { "type": "int"}
}
}
}
}
}
这是我从 REST API 获得的数据
{
"test.mydomain_1.xyz:1019": {
"infoAddr":"x.x.x.x:1022",
"usedSpace":384635032546,
"capacity":30697676811776,
"version":"2.7.3.2.6.5.23-1",
"used":384635032546,
"remaining":30311575148182,
"volfails":0 },
"test.mydomain_2.xyz:1019": {
"infoAddr":"x.x.x.x:1022",
"usedSpace":384635032546,
"capacity":30697676811776,
"version":"2.7.3.2.6.5.23-1",
"used":384635032546,
"remaining":30311575148182,
"volfails":0 }
}
现在我有清单
1. clusterName = ("test.mydomain_1.xyz:1019", "test.mydomain_2.xyz:1019",..."test.mydomain_n.xyz:1019")
2. Properties under properties field = ("infoAddr", "usedSpace",..."volfails")
3. Type of values from properties = ("str","str",..."int")
请建议我如何使用循环从这些数据创建映射,以便自动创建此映射。
沧海一幻觉
四季花海
相关分类