【问题标题】:Composite Index in Google Cloud DatastoreGoogle Cloud Datastore 中的复合索引
【发布时间】:2020-09-06 22:08:07
【问题描述】:

我有一个好听的名字'Wdr'。我的 index.yaml 文件如下所示。

indexes:
-kind: Wdr
 ancestor: yes
 properties:
 -name : wdr_id
 -name : wdr_sub_id
  direction: desc

我无法在下面运行这个 gql 查询。

SELECT * FROM  Wdr where wdr_id = '1098' order by wdr_sub_id desc 

我得到的错误是..

GQL Query error: Your Datastore does not have the composite index (developer-supplied) required for this query.

.yaml 文件中定义的索引是否不正确?还是我在这里做错了什么?

【问题讨论】:

    标签: google-cloud-platform google-cloud-datastore gql gqlquery composite-index


    【解决方案1】:

    您的索引定义包含ancestor: yes,这意味着您的查询应该包含祖先过滤器。您可以将祖先过滤器添加到查询中,也可以将索引定义更改为 ancestor: no

    【讨论】:

    • 'SELECT * from Wdr WHERE key HAS ANCESTOR Key(Tan, 'f347e5bd-8204-4ff1-b7a5-ae2b65a7ac38') ORDER BYwelder_sub_id asc ' 这个查询没有也工作过
    • 'SELECT * from Wdr WHERE key HAS ANCESTOR Key(Tan, 'f347efbd-8204-4ff1-b7a5-aecb65a7ac38') ORDER BY wd_start_time asc' 应该使用哪些索引我为这个查询添加?
    • 尝试使用查询的错误消息应该提供所需的索引。我希望它是kind: Wdr ancestor: yes properties: -name : wdr_sub_id/wd_start_time direction: asc
    猜你喜欢
    • 1970-01-01
    • 2021-01-13
    • 1970-01-01
    • 1970-01-01
    • 2018-08-25
    • 2020-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多