【发布时间】:2014-06-07 11:22:06
【问题描述】:
我一直在使用复合索引运行地理空间查询。
升级到 MongoDB 2.6 后,结果集的顺序发生了变化,因此以下查询的结果不再按距离排序:
db.properties.find({
"address.uppercase": { "$regex": "^14529" },
"address.location": {
"$near": {
"$geometry": {
"type": "Point",
"coordinates": [ -122.2103, 47.6154 ]
}
}
}
})
属性集合上的索引配置为:
{ "address.uppercase": 1, "address.location": "2dsphere" }
在 2.4 中,查询返回“address.uppercase”以“14529”开头的所有地址,按与位置[ -122.2103, 47.6154 ]的地址距离排序。
升级到 2.6 后,相同的查询现在返回所有按“address.uppercase”排序的地址。
有没有办法根据查询的地理空间部分指定结果的排序顺序?
【问题讨论】:
标签: mongodb geospatial