Cloud Datastore is a highly-scalable NoSQL database for web and mobile applications. For writing complex queries in Datastore composite indexes are required. Follow this tutorial for creating composite indexes with cloud shell.
This tutorial assumes you have below kind and properties already available in Datastore
Login to Google Cloud Console
Click Activate Cloud Shell to open Cloud Shell.
Create a file index.yaml
nano index.yaml
For creating composite index on all three properties, write below code in index.yaml
indexes:
- kind: post
ancestor: no
properties:
- name: url
- name: title
- name: date-posted
Create composite index with
gcloud datastore indexes create index.yaml
Above command will ask for confirmation , check listed configurations and confirm, successful execution should display created index in Indexes section of Datastore UI.
Category: GCP