2017-10-20 65 views
1

我在Google App Engine上使用灵活的环境google cloud datastore library查询谷歌云数据存储与祖先没有返回任何东西

我有我的父母使用pathway实体run实体:

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> 

如果我取一些pathway实体,他们似乎有正确的父

pathways = ds.query(kind='pathway', order=('-timestamp',)).fetch(limit=10) 

for pathway in pathways: 
    print(pathway.key.parent) # <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 

如何正确过滤父实体?

回答