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
如何正確過濾父實體?
啊謝謝!看來我完成了錯過了有關指數的位。 –