how to create index GCP datastore?

91 Views Asked by At

I have created a project in GCP and I am using two datastore in it one is the default one and the second is named "secondary" I want to create index for secondary datastore but I am not able to create index for that one because I didn't find any information regarding nondefault datastore. What I tried is following few commands

gcloud datastore indexes create index.yaml // This creates index on default datastore

gcloud datastore indexes create index.yaml --datastore=secondary // This one gives an error 

gcloud datastore indexes create index.yaml --namespace=secondary //This one gives an error 
2

There are 2 best solutions below

4
NoCommandLine On BEST ANSWER

According to the documentation, it should be

gcloud datastore indexes create INDEX_FILE [--database=DATABASE] 

and so for your case, try

gcloud datastore indexes create index.yaml --database=secondary

Updates

Per the release notes, you have to use GCloud SDK 459.0.0 or higher because that is where support for the --database flag became available in beta and GA

Promoted --database flag of gcloud datastore indexes create command to beta. Promoted --database flag of gcloud datastore indexes create command to GA.

0
iamwillbin On

Try using

gcloud datastore indexes create index.yaml --namespace=your-namespace

It will create the index as per the specifications in the index.yaml file for the specified namespace.

The index.yaml file should contain the index definitions for the secondary Cloud Datastore. Make sure the index.yaml file is correctly structured with the appropriate index definitions for the entities in the specified namespace.