Azure Table 通过 REST api returns 错误请求对行键进行存储范围查询
Azure Table Storage Range query on RowKeys through REST api returns bad request
在对 Azure Table 存储 api 的 ajax 请求中,我指定以下内容 url
url:'https://myaccount.table.core.windows.net/mytable(PartitionKey=\'2016-01-12_1\')?$filter=RowKey+ge+1',
收到错误的请求响应。我尝试了一些修改,例如在过滤器中的单词之间使用纯空格或使用 %20
,但结果是一样的。
我确定这个分区存在并且包含大于 1 的值。
如果 url 的形式为:
url:'https://myaccount.table.core.windows.net/mytable(PartitionKey=\'2016-01-12_1\',RowKey=\'someValue\'),
然后就可以了。但我不能让它与过滤器一起工作。有什么想法可能会出错吗?
我认为您使用不当。如果您在方括号中指定 PartitionKey
,那么您也必须在其中使用 RowKey
。您不能混合使用这 2 个选项。
来自 Querying Tables and Entities
:
Because the PartitionKey and RowKey properties form an entity's
primary key, you can use a special syntax to identify the entity, as
follows:
https://myaccount.table.core.windows.net/Customers(PartitionKey='MyPartition',RowKey='MyRowKey1')
如果您想在 RowKey
上过滤某些 PartitionKey
值,您必须仅在 $filter
中指定 PartitionKey
。所以你的请求 URL 将是:
https://myaccount.table.core.windows.net/mytable()?$filter=PartitionKey eq 'PartitionKeyValue' and RowKey ge 'RowKeyValue'
在对 Azure Table 存储 api 的 ajax 请求中,我指定以下内容 url
url:'https://myaccount.table.core.windows.net/mytable(PartitionKey=\'2016-01-12_1\')?$filter=RowKey+ge+1',
收到错误的请求响应。我尝试了一些修改,例如在过滤器中的单词之间使用纯空格或使用 %20
,但结果是一样的。
我确定这个分区存在并且包含大于 1 的值。
如果 url 的形式为:
url:'https://myaccount.table.core.windows.net/mytable(PartitionKey=\'2016-01-12_1\',RowKey=\'someValue\'),
然后就可以了。但我不能让它与过滤器一起工作。有什么想法可能会出错吗?
我认为您使用不当。如果您在方括号中指定 PartitionKey
,那么您也必须在其中使用 RowKey
。您不能混合使用这 2 个选项。
来自 Querying Tables and Entities
:
Because the PartitionKey and RowKey properties form an entity's primary key, you can use a special syntax to identify the entity, as follows:
https://myaccount.table.core.windows.net/Customers(PartitionKey='MyPartition',RowKey='MyRowKey1')
如果您想在 RowKey
上过滤某些 PartitionKey
值,您必须仅在 $filter
中指定 PartitionKey
。所以你的请求 URL 将是:
https://myaccount.table.core.windows.net/mytable()?$filter=PartitionKey eq 'PartitionKeyValue' and RowKey ge 'RowKeyValue'