gpt4 book ai didi

python-3.x - gcloud 数据存储 : Can I filter with IN or Contains operator?

转载 作者:行者123 更新时间:2023-12-02 20:27:22 28 4
gpt4 key购买 nike

我是数据存储区 gCloud 的新手。我想在一个名为 Score 的实体中过滤与公司列表相关的所有分数。我的实体的组成如下:

{
    "company_id": 1,
    "score": 100,
}

我有几个具有不同公司 ID 的实体。我尝试使用 query.add_filter 命令进行过滤,但收到错误 ValueError:

('Invalid expression: "IN"', 'Please use one of: =, <, <=,>,> =.')

错误的原因对我来说非常清楚,但除了上述错误消息中列出的类型之外,我还没有在文档中找到有关如何使用 IN 或 CONTAINS 运行过滤器的任何内容。

最佳答案

数据存储区不支持您寻找的过滤器运算符。唯一受支持的列于 Filters 中。 :

The comparison operator can be any of the following:

Operator                  Meaning
EQUAL Equal to
LESS_THAN Less than
LESS_THAN_OR_EQUAL Less than or equal to
GREATER_THAN Greater than
GREATER_THAN_OR_EQUAL Greater than or equal to

某些客户端库可能提供一些等效项,但有限制。例如,标准环境 GAE 特定的 ndb 库(在您的上下文中不可用)提供了此类支持。来自 The != and IN Operations 的示例可能很有用,因为您可以在代码中以类似的方式实现它:

Similarly, the IN operation

property IN [value1, value2, ...]

which tests for membership in a list of possible values, is implemented as

(property == value1) OR (property == value2) OR ...

关于python-3.x - gcloud 数据存储 : Can I filter with IN or Contains operator?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49582670/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com