Open vipinsorot opened 1 year ago
Thank you for reaching out about this issue. By default, when querying a Cosmos DB container using the SDK, cross-partition queries are disabled. This is because you should try and limit executing cross-partition queries as much as possible by ensuring the partition key is included in your queries. While cross-partition queries are sometimes unavoidable and OK, excessive querying across partitions comes with a high cost (in RU/s and performance).
What you need to do in your application code that is making the call to your new container is to update the FeedOptions
to enable cross-partition queries with the EnableCrossPartitionQuery
property. Here's an example:
var queryable = client.CreateDocumentQuery<Book>(
collectionLink, new FeedOptions { EnableCrossPartitionQuery = true }).Where(b => b.Price > 1000);
Thanks @joelhulen for quick response
One of our customers mentioned the query was working fine for them without adding crosspartitionquery for their old account .But on the new account with exact same configuration it is giving this error .Was there a change implemented which worked for old accounts and stopped working off late ?
I have migrated a collection, post migration when i am switching to new db endpoints, i am getting an error Error:Cross partition query is required but disabled. Please set x-ms-documentdb-query-enablecrosspartition to true, specify x-ms-documentdb-partitionkey, or revise your query to avoid this exception., documentdb-dotnet-sdk/2.11.6
sharing old collection setting new collection setting