Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 查询Google云数据存储时,祖先不返回任何内容_Python_Google App Engine_Google Cloud Datastore - Fatal编程技术网

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