Cosmos DB:跨分区查询不能直接由网关提供服务 [英] Cosmos DB : cross partition query can not be directly served by the gateway

查看:88
本文介绍了Cosmos DB:跨分区查询不能直接由网关提供服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何想法为什么当我使用其余api在Cosmos DB中执行以下查询时我收到以下错误?相同的查询,但不按顺序工作正常...

Any idea why when I execute the query below in Cosmos DB using the rest api I get the error below? The same query without the order by works fine...

在两种情况下,我都设置了标头"x-ms-documentdb-query-enablecrosspartition:True" ,并且我正在使用PHP发出请求.

I have set the header "x-ms-documentdb-query-enablecrosspartition: True" in both cases and I am using PHP to make the requests.

有效的多分区查询:

从c中选择c.id,c.name,c.age,其中c.age = 30

SELECT c.id, c.name, c.age FROM c where c.age = 30

具有错误的多分区查询:

MULTI PARTITION QUERY WITH ERROR:

从c中选择c.id,c.name,c.age,其中c.age = 30(按c.age asc排序)

SELECT c.id, c.name, c.age FROM c where c.age = 30 order by c.age asc

错误:

客户端错误: POSThttps://yeapp-cosmosdb.documents.azure.com//dbs/-JJZAA==/colls/-JJZAL+WPKw=/docs

导致 400 BadRequest 响应:{"code":"BadRequest","message":"提供的跨分区查询可以不能直接由网关提供服务.这是(被截断的...)

resulted in a 400 BadRequest response: {"code":"BadRequest","message":"The provided cross partition query can not be directly served by the gateway. This is a (truncated...)

推荐答案

我只是遇到了同样的问题,在我看来这是最近才显现出来的.我以前没有.当我在具有联接的查询上使用SELECT DISTINCT时,我遇到了同样的问题.这就是为什么

I just had the same problem, which seems to me just recently manifested. I did not have it before. I have the same problem when I use SELECT DISTINCT on a query with joins...and here is why https://docs.microsoft.com/en-us/rest/api/cosmos-db/querying-cosmosdb-resources-using-the-rest-api#Queries-that-cannot-be-served-by-gateway

如果您删除ORDER BY,而在我的情况下为DISTINCT,则查询有效...

If you remove the ORDER BY, and in my case the DISTINCT, the query works...

这很不幸.注意:相同的查询在Azure门户中有效,但在REST API中无效.但是,Azure门户会迫使您浏览分页的结果,这并不是获取长查询结果或自动任务的真正方法...

This is unfortunate. Note: the same query works from the Azure Portal, but not from the REST API. The Azure portal however forces you to go through the paginated results and it is not really the way to go for long query results or automated tasks...

从上面的链接中我们可以看到:

From the above link we can see this:

网关无法为任何需要跨连续状态的查询提供服务.这包括:最佳订购偏移极限骨料清楚的通过...分组网关可以提供的查询包括:简单的预测过滤器

这篇关于Cosmos DB:跨分区查询不能直接由网关提供服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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