google-cloud-platformindexingnosqlgoogle-cloud-datastoregcloud

how to create index GCP datastore?


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 

Solution

  • 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.