6***@qq.com
6***@qq.com
  • 发布:2022-11-14 17:36
  • 更新:2022-11-14 18:05
  • 阅读:230

unicloud 根据经纬查询结果报错

分类:uniCloud

表结构已经设置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

2022-11-14 17:36 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ

DCloud_uniCloud_WYQ

你查询用的是point字段,索引配置的是location字段。

该问题目前已经被锁定, 无法添加新回复