J'utilise le google cloud datastore library un environnement flexible sur Google App Engine.Interrogation du magasin de données Google Cloud avec l'ancêtre ne renvoyant rien
J'ai une entité run
que je l'utilise en tant que parent pour pathway
entités:
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>
Si je vais chercher quelques pathway
entités, ils semblent avoir le parent correct
pathways = ds.query(kind='pathway', order=('-timestamp',)).fetch(limit=10)
for pathway in pathways:
print(pathway.key.parent) # <Key('run', 1), project=project-name>
Mais si je essayez de filtrer avec le parent comme ceci:
pathways = ds.query(kind='pathway', ancestor=parent.key, order=('-timestamp',)).fetch(limit=10)
Puis-je obtenir une erreur:
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
Comment filtrer correctement avec l'entité mère?
Ah merci! Il semble que j'ai terminé raté le bit sur les index. –