问题
I'm using .net core Cosmos Db Client nuget Microsoft.Azure.Cosmos v3.4.4
I need to query across partition but I haven't found how to do this like FeedOptions.EnableCrossPartitionQuery as described in the following article https://docs.microsoft.com/en-us/azure/cosmos-db/how-to-query-container
Can you help me?
Thanksss!
回答1:
Cross partition queries are enabled by default in V3.
If you do specify a PartitionKey
in the QueryRequestOptions
, it becomes a single partition query.
Source code reference: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/RequestOptions/QueryRequestOptions.cs#L156
回答2:
https://github.com/Azure/azure-cosmos-dotnet-v3/issues/731
The v3 SDK sets the EnableCrossPartitionQuery automatically based on the query and QueryRequestOptions.PartitionKey value. There is no need to set it in v3.
回答3:
If you are using CosmosDB SDK v3 Cross Partition Queries are enabled by default.
There is no longer "FeedOptions", instead EnableCrossPartitionQuery is set automatically based on the query
来源:https://stackoverflow.com/questions/58633950/enable-query-across-partitions-on-microsoft-azure-cosmos-client