【发布时间】:2017-06-12 07:29:06
【问题描述】:
我在 Cloudant 中使用地理空间索引来检索多边形内的所有文档。现在我想为这些文档计算一些基本的静态值(例如,一个地区的平均年龄和收入总和)。
是否可以查询地理索引,然后将结果传递给 MapReduce 函数?
我怎样才能做到这一点,最好是在数据库中?我是否可以避免先查询多边形内的文档 ID,然后发送检索到的 ID 以执行 MapReduce(我正在处理大型数据集)?
目前的工作是查询索引以及使用视图(单独)。
我的地理索引
function (doc) {
if (doc.geometry && doc.geometry.coordinates) {
st_index(doc.geometry);
}
}
我的看法
function (doc) {
var beitrag = doc.properties.beitrag;
var schadenaufwand = doc.schadenaufwand;
if(beitrag !== null && typeof beitrag === 'number' ) {
emit(doc._id, doc.properties.beitrag);
}
}
geoJson 文档示例(原始数据看起来很相似)
{
"_id": "01bff77f642fc4249e787d2ded011504",
"_rev": "1-25a9a1a15939d5b21af3fbcc5c2d6ed1",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
7.2316,
40.99
]
},
"properties": {
"age": 34,
"earnings": 982.7
}
}
这个问题很相似,但并没有真正帮助我:Cloudant - apply a view/mapReduce to a geospatial query
这个演示可能是正确的方向:https://examples.cloudant.com/simplegeo_places/_design/geo/index.html
【问题讨论】:
标签: node.js geospatial geojson cloudant