Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure Cosmos:具有JOIN和ORDER BY的不同结果_Azure_Distinct_Azure Cosmosdb - Fatal编程技术网

Azure Cosmos:具有JOIN和ORDER BY的不同结果

Azure Cosmos:具有JOIN和ORDER BY的不同结果,azure,distinct,azure-cosmosdb,Azure,Distinct,Azure Cosmosdb,我正在尝试编写一个查询,该查询使用JOIN对数组中的位置执行地理空间匹配。我让它工作了,但是添加了DISTINCT以消除重复(查询A): 然而,我随后发现,除非您还添加了orderby,否则不支持将DISTINCT与continuation标记相结合: System.ArgumentException: Distict query requires a matching order by in order to return a continuation token. If you would

我正在尝试编写一个查询,该查询使用
JOIN
对数组中的位置执行地理空间匹配。我让它工作了,但是添加了
DISTINCT
以消除重复(查询A):

然而,我随后发现,除非您还添加了
orderby
,否则不支持将
DISTINCT
与continuation标记相结合:

System.ArgumentException: Distict query requires a matching order by in order to return a continuation token. If you would like to serve this query through continuation tokens, then please rewrite the query in the form 'SELECT DISTINCT VALUE c.blah FROM c ORDER BY c.blah' and please make sure that there is a range index on 'c.blah'. 
所以我试着像这样(Query B)添加
ORDER BY

问题是,
DISTINCT
似乎不再生效,因为它返回(例如)同一条记录两次

要复制此数据,请使用此数据创建单个文档:

{
    "id": "b6dd3e9b-e6c5-4e5a-a257-371e386f1c2e",
    "locations": [
        {
            "latitude": -42,
            "longitude": -109
        },
        {
            "latitude": -42,
            "longitude": -109
        }
    ],
    "created": "2019-03-06T03:43:52.328Z"
}
然后运行上面的查询A。您将得到一个结果,尽管两个位置都匹配谓词。如果删除不同的
,您将获得相同的文档两次

现在运行queryb,您将看到它两次返回相同的文档,尽管有
DISTINCT
子句


我做错了什么?

复制了您的问题确实,根据我的研究,它似乎是cosmos db
distinct
查询中的一个缺陷。请参阅此链接:

此功能在数据资源管理器中中断。因为宇宙只能 每页一次返回100个结果,distinct关键字只会 应用于单个页面。因此,如果结果集包含100多个 结果,你仍然可以得到重复的-他们只是简单地在屏幕上 单独分页的结果集


您可以描述自己的情况并投票支持此反馈案例。

您好,我的答案对您有帮助吗?您好,如果我的答案对您有帮助,您可以将其标记为答案吗?如果没有,请让我帮你。嗨,我的回答对你有帮助吗?
SELECT DISTINCT VALUE
    u
FROM
    u
JOIN loc IN u.locations
WHERE
    ST_WITHIN(
        {'type':'Point','coordinates':[loc.longitude,loc.latitude]},
        {'type':'Polygon','coordinates':[[[-108,-43],[-108,-40],[-110,-40],[-110,-43],[-108,-43]]]})
ORDER BY
    u.created
{
    "id": "b6dd3e9b-e6c5-4e5a-a257-371e386f1c2e",
    "locations": [
        {
            "latitude": -42,
            "longitude": -109
        },
        {
            "latitude": -42,
            "longitude": -109
        }
    ],
    "created": "2019-03-06T03:43:52.328Z"
}