查询操作的 Orion 内部服务器错误(溢出排序)

Orion internal server error with query operation (overflow sort)

使用 Orion context broker,有时我会收到以下错误消息 在进行分页查询时(例如 POST /v1/queryContext?offset=3900&limit=100):

 [{
   "contextElement": {
     "type": "device",
     "id": ".*",
     "isPattern": "true"}
   "statusCode": {
     "code": "500",
     "details": "Error at querying MongoDB",
     "reasonPhrase": "Internal Server Error"
   }
 }]

查看 Orion 日志我发现以下消息:

Database Error (Runner error: Overflow sort stage buffered data usage of 33557262 bytes exceeds internal limit of 33554432 bytes)

请问如何解决这个问题?

根据现有信息(this and this), it could be due to an index is needed for the field used for sorting. Orion uses creDate for sorting entities result, so creating an index 该字段可能有所帮助,例如:

db.entities.ensureIndex( { creDate: 1 } ) 

可以找到有关 Orion 推荐索引的更多信息 in the following section of the Orion manual