表结构已经设置location为索引,图在附件
字段:
"location":{
"bsonType": "object",
"title": "经纬度",
"properties": {
"latitude": {
"bsonType": "double",
"title": "经度"
},
"longitude": {
"bsonType": "double",
"title": "纬度"
}
}
},
查询语句是:
try {
const db = uniCloud.database();
let res = await db.collection('food_store').where({
point: db.command.geoNear({
geometry: new db.Geo.Point(112.986283, 28.244104),
maxDistance: 1000,
minDistance: 0
})
}).get()
console.log(res)
} catch (e) {
console.log(e)
}
报错:
Error: Query failed with error code 291 and error message 'error processing query: ns=db_VKCEYUGU_5079365a-eafb-4963-b27b-68a6e49922b6.food_store limit=1Tree: $and
$or
$and
state $eq false
user_id $eq null
$and
state $eq false
$not
user_id $eq null
$and
state $eq false
$not
user_id $eq null
GEONEAR field=point maxdist=1000 isNearSphere=0
Sort: {}
Proj: {}
planner returned error :: caused by :: unable to find index for $geoNear query' on server 192.168.146.101:3717