COSMOS DB集合中的多个分区 [英] Multiple Partitions in COSMOS DB collection

查看:90
本文介绍了COSMOS DB集合中的多个分区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1) I have a Cosmos DB collection with about 500k documents and which is Partitioned by a property "SITEID". In the Query Request Options only one partition key value can be passed. In my case I have queries where the SITEID in (1,2,3,4) needs to be executed where SiteID is the partition key. For example, My SP is as follows:

在c.SITEID IN("SiteId1","SiteId2","SiteId3","SiteId4","SiteId5")和c.STATUS IN("Status1","Status2")中选择* ,"Status3","Status4")

SELECT * FROM c WHERE c.SITEID IN ("SiteId1","SiteId2","SiteId3","SiteId4","SiteId5") AND c.STATUS IN ("Status1","Status2","Status3","Status4")

我正在使用下面的SQL API代码调用上面的SP.

I am Calling the above SP using the below SQL API code.

等待客户端.ExecuteStoredProcedureAsync(UriFactory.CreateStoredProcedureUri("DBName","CollectionName","Sample"),new RequestOptions {PartitionKey = new PartitionKey("SiteId1"))})

await client.ExecuteStoredProcedureAsync(UriFactory.CreateStoredProcedureUri("DBName", "CollectionName", "Sample"),new RequestOptions { PartitionKey = new PartitionKey("SiteId1") })

在上面的SQL API代码中,PartitionKey属性仅支持Single值.我需要传递几个分区值.还有其他选择吗?

In the above SQL API Code, PartitionKey property only supports a Single value. Where I need to pass several partition values. Is there any other options to do this?

2)"EnableCrossPartitionQuery";属性仅在FeedOptions中可用,而在Request Options类中则不可用. Client.ExecuteStoredProcedureAsync仅支持RequestOptions参数,而不支持FeedOptions.现在我需要执行一个存储过程 一次跨越所有分区.还有其他选项可以通过ExecuteStoredProcedureAsync方法传递EnableCrossPartitionQuery.

2) "EnableCrossPartitionQuery" property is only availbale in the FeedOptions but not in the Request Options class. Client.ExecuteStoredProcedureAsync only supports the RequestOptions parameter not FeedOptions. Now I need to execute a Stored Procedure at once and across all partitions. Is there any other options to pass EnableCrossPartitionQuery in ExecuteStoredProcedureAsync method.

例如)

client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri("DBName","CollectionName"),从c选择*",新的FeedOptions {EnableCrossPartitionQuery = true}).ToList()

client.CreateDocumentQuery(UriFactory.CreateDocumentCollectionUri("DBName", "CollectionName"), "select * from c", new FeedOptions { EnableCrossPartitionQuery = true }).ToList()

等待客户端.ExecuteStoredProcedureAsync(UriFactory.CreateStoredProcedureUri("DBName","CollectionName","Sample"),new RequestOptions {PartitionKey = new PartitionKey("WGC")})

await client.ExecuteStoredProcedureAsync(UriFactory.CreateStoredProcedureUri("DBName", "CollectionName", "Sample"),new RequestOptions { PartitionKey = new PartitionKey("WGC") })

任何帮助都将非常有用.

Any help would be great.

推荐答案

Naveen,

Naveen,

我将为您提供一些资源进行审查:

I am going to provide you with a couple resources to review: 

W

What is the advised way to query documents from different partitions in COSMOSDB?

要完成的10件事了解DocumentDB分区集合

请让我们知道您可能还有其他问题.

Please let us know what additional questions you might have.

此致

迈克


这篇关于COSMOS DB集合中的多个分区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆