Python 查询Google云数据存储时,祖先不返回任何内容
我正在谷歌应用程序引擎上使用灵活的环境 我有一个Python 查询Google云数据存储时,祖先不返回任何内容,python,google-app-engine,google-cloud-datastore,Python,Google App Engine,Google Cloud Datastore,我正在谷歌应用程序引擎上使用灵活的环境 我有一个运行实体,我将其用作路径实体的父实体: ds = datastore.Client('project-name') parent = ds.query(kind='run', order=('-timestamp',)).fetch(1) parent = list(parent)[0] print(parent.key) # <Key('run', 1), project=project-name> 但如果我尝试像这样与家长
运行
实体,我将其用作路径
实体的父实体:
ds = datastore.Client('project-name')
parent = ds.query(kind='run', order=('-timestamp',)).fetch(1)
parent = list(parent)[0]
print(parent.key) # <Key('run', 1), project=project-name>
但如果我尝试像这样与家长一起过滤:
pathways = ds.query(kind='pathway', ancestor=parent.key, order=('-timestamp',)).fetch(limit=10)
然后我得到一个错误:
google.api.core.exceptions.PreconditionFailed
google.api.core.exceptions.PreconditionFailed: 412 no matching index found. recommended index is:
- kind: pathway
ancestor: yes
properties:
- name: timestamp
direction: desc
如何正确过滤父实体?为了满足某些查询,云数据存储需要构建索引。详情如下:
定义建议的索引应该可以使有问题的查询正常工作。啊,谢谢!看来我错过了关于索引的部分。
google.api.core.exceptions.PreconditionFailed
google.api.core.exceptions.PreconditionFailed: 412 no matching index found. recommended index is:
- kind: pathway
ancestor: yes
properties:
- name: timestamp
direction: desc