Search code examples
google-cloud-datastore

How to configure namespace for composite index in Datastore?


I have a kind events that is stored in different namespaces which depends on service stage (dev/stage/prod).

I want to add composite index only for a kind in dev namespace but I can't find a way to configure it

I use command to create the index:

gcloud datastore indexes create ~/myapp/index.yaml

index.yaml

indexes:

- kind: events
  properties:
  - name: created
    direction: desc
  - name: approved
    direction: desc

Do you know a way to create an index only for one namespace?


Solution

  • Composite indexes are per database, and thus cross namespaces. There is no way to configure a composite index per namespace.

    There is some other details in Are datastore indexes same across multiple namespaces? .