Azure Table 存储的 `endsWith` 和 `startsWith`

`endsWith` and `startsWith` for Azure Table Storage

我通过 Node.js 在 CosmosDB 上使用 Azure Table 存储。我想出了一个使用大于和小于来提供 startsWith 功能的技巧。

另一方面,我仍然需要 endsWith 功能,但找不到让它工作的方法。这可能是我必须拉入所有分区键或行键然后自己进行字符串搜索的情况之一。

我注意到 Azure Table 具有与 odata 相同的查询格式,在 $filter 的本文档中,我看到列出了一个 endsWith 命令:https://docs.microsoft.com/en-us/previous-versions/dynamicsnav-2016/hh169248(v=nav.90)

是否有可用的 endsWith 命令,或者是否有查询所有分区键或行键并自己进行搜索的方法?

Is there an endsWith command available or instead, is there a way to query all the partition or row keys and do the search myself?

不幸的是,startsWithendsWith 命令在 Azure Table 存储中都不可用。对于 startsWith,我猜您实施了类似于此处概述的解决方案的 hack:.

但是 endsWith 没有这样的黑客可用。不过,一种可能性是将另一个实体存储在您反转 PartitionKey(或 RowKey)的位置,然后应用 startsWith hack。例如,您的 PartitionKeyabcdef,您需要找到以 ef 结尾的实体,您可以将另一个以 PartitionKey 结尾的实体存储为 fedcba,然后使用 fe 应用 startsWith hack(再次反转您正在搜索的字符串)。