Azure cosmosdb 如何在Azure DocumentDB中执行类似于SQL联接的联接操作

Azure cosmosdb 如何在Azure DocumentDB中执行类似于SQL联接的联接操作,azure-cosmosdb,Azure Cosmosdb,我在Azure DocumentDB中有一个集合,在其中,我为每个文档使用名为clusterName的JSON属性将文档聚集成3个集合。这3组文档的模板有点像: { “clusterName”:“CustomerInformation”, “id”:“CustInfo1001”, “客户名称”:“XXXX” }, { “clusterName”:“区域信息”, “id”:“ZoneInfo 5005”, “zoneName”:“YYYY” }, { “clusterName”:“Customer

我在Azure DocumentDB中有一个集合,在其中,我为每个文档使用名为clusterName的JSON属性将文档聚集成3个集合。这3组文档的模板有点像:

{ “clusterName”:“CustomerInformation”, “id”:“CustInfo1001”, “客户名称”:“XXXX” },

{ “clusterName”:“区域信息”, “id”:“ZoneInfo 5005”, “zoneName”:“YYYY” },

{ “clusterName”:“CustomerZoneAssociation”, “id”:“CustZoneAss9009”, “custId”:“CustInfo1001”, “zoneId”:“ZoneInfo 5005” }

如您所见,CustomerZoneAssociation的文档将CustomerInformationZoneInformation的文档与其Id链接起来。我需要在CustomerZoneAssociation集群中关联的Id的帮助下从CustomerInformation和ZoneInformation集群查询信息。我期待的查询结果是:

{ “clusterName”:“CustomerZoneAssociation”, “id”:“CustZoneAss9009”, “custId”:“CustInfo1001”, “客户名称”:“XXXX”, “zoneId”:“ZoneInfo 5005”, “zoneName”:“YYYY” }


请建议一个只需一次访问DocumentDB的解决方案。DocumentDB不支持文档间连接。。。相反,
JOIN
关键字用于执行文档内交叉乘积(与嵌套数组一起使用)

我建议采取以下方法之一:

  • 请记住,您不必像使用传统RDBMS那样规范化每个实体。可能值得重新审视您的数据模型,并在适当的情况下对部分数据进行反规范化。还要记住,反规范化有其自身的权衡(散开写入与发布后续读取)。请查看以下答案,以便阅读更多有关

  • 编写一个存储过程以在单个网络请求中批处理一系列操作。检查以下内容,以便回答问题


第二个要点中的代码示例不执行跨表联接。