【发布时间】:2015-03-30 16:35:22
【问题描述】:
我有来自 Javascript ElasticSearch 查询的以下响应,我需要将其映射到以下结构。有没有比我目前正在做的更有效的方法?
谢谢
我需要映射到的结构:(其中大约 700 个)
[{
"coordinates": ["48", "37"],
"name": "something",
"population": "501"
},
我返回的数据的当前结构:
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]
0: Object
_id: "4"
_index: "locationIndex"
_score: 1
_source: Object
coordinates: Array[2]
0: -77.080597
1: 38.892899
length: 2
__proto__: Array[0]
name: "someName"
population: 57205
1: Object
...
我正在尝试但失败了:
var results= [{
"key": 'coordinates',
resp.coordiantes[0],
resp.coordinates[1],
"key": 'name',
resp.name
})
}];
【问题讨论】:
标签: javascript arrays object dictionary elasticsearch