google-cloud-platformgoogle-cloud-datastoregqlgqlquerycomposite-index

Composite Index in Google Cloud Datastore


I have a kind name 'Wdr'. My index.yaml file looks like this .

indexes:
-kind: Wdr
 ancestor: yes
 properties:
 -name : wdr_id
 -name : wdr_sub_id
  direction: desc

I am not able to run this gql query below.

SELECT * FROM  Wdr where wdr_id = '1098' order by wdr_sub_id desc 

The eror i get is..

GQL Query error: Your Datastore does not have the composite index (developer-supplied) required for this query.

Is the indexes define in the .yaml file is not correct? or am i doing something else wrong here?


Solution

  • Your index definition contains ancestor: yes, this means that your query should contain an ancestor filter. You can either add an ancestor filter to your query or change your index definition to ancestor: no.