我有一个带有分区键" flightConversationId"的集合。
我正在做一个非常简单的查询,通过PARTITON KEY FIELD
SELECT * from root WHERE root.flightConversationId="b36d13c0-cbec-11e7-a4ad-8fcedf370f98"
当通过nodeJS SDK执行此查询时,它将工作一秒钟,并在下一个错误时失败:
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.
我意识到我可以启用跨分区查询,但我不需要跨分区查询。发生了什么???
答案 0 :(得分:0)
这种情况似乎随着时间的推移而自行解决。
我的理论是,当我们删除一个集合并使用新的分区键重新创建它时,原始集合的所有残余都需要很长时间才能真正从云中删除,并且有些请求会转到“旧的“与”新“同名的集合。
答案 1 :(得分:-1)
您必须通过提供具有FeedOptions
属性的RequestOptions
或partitionKey
类来明确地将查询范围限定为分区。在没有明确范围的情况下,在where子句中使用PartitionKey是不够的。这适用于C#,但应该是相同的对象模型:
https://docs.microsoft.com/en-us/azure/cosmos-db/documentdb-partition-data
Document result = await client.ReadDocumentAsync(
UriFactory.CreateDocumentUri("db", "coll", "XMS-001-FE24C"),
new RequestOptions { PartitionKey = new PartitionKey("XMS-0001") });
jsDoc:
http://azure.github.io/azure-documentdb-node/global.html#RequestOptions http://azure.github.io/azure-documentdb-node/global.html#FeedOptions