Azure:不支持DocumentDB Mongo $组

Ans*_*oka 15 azure mongodb azure-cosmosdb

将我的Mongo应用程序迁移到Azure上的DocumentDB后,$group查询不再有效并抛出以下错误:

{ MongoError: '$group' is not supported',
  name: 'MongoError',
  message: '\'$group\' is not supported',
  _t: 'OKMongoResponse',
  ok: 0,
  code: 115,
  errmsg: '\'$group\' is not supported',
  '$err': '\'$group\' is not supported' }
Run Code Online (Sandbox Code Playgroud)

有没有其他人遇到这个,可能有任何建议吗?

Saj*_*ran 6

有两种方法可以尝试

(i)您可以尝试按照documentdb-lumenizeLarry Maccherone的说法,(Group-by, Pivot-table, and N-dimensional Cube)在DocumentDB中提供聚合和时间序列转换作为存储过程

(ii)最近cosmosdb支持此功能,您可以通过预览功能窗格启用此功能并启用MongoDB聚合pipleline.请点击以下链接

Aggregation in cosmos-db

在此输入图像描述


小智 0

对于任何在 2018 年以后尝试解决此问题的人来说,DocumentDB 现在支持此功能,但默认情况下处于关闭状态。您必须进入 Azure 中的“预览功能”窗格并打开“MongoDB 聚合管道”才能访问 $group。

对于有兴趣了解更多信息的人,他们的公告如下。

https://azure.microsoft.com/en-in/blog/azure-cosmosdb-extends-support-for-mongodb-aggregation-pipeline-unique-indexes-and-more/