Home > Back-end >  Create composite index in AppEngine Firestore in Native Mode
Create composite index in AppEngine Firestore in Native Mode

Time:09-17

We are currently developing an AppEngine Standard application using Cloud Firestore in Native Mode which is working very well. Now, we want to support a query that needs a composite index which we try to create using a index.yaml file:

indexes:
  - kind: myentity
    properties:
      - name: owner
        direction: asc
      - name: created_at
        direction: asc

When testing this with gcloud app deploy index.yaml, we observe that indexes are being created. However, the created indexes are Cloud Datastore indexes not Cloud Firestore ones, even though Datastore is "not even enabled" (The Cloud console wants to send you directly to Firestore view if you try to access the Datastore view). Therefore, our queries are failing. How do we instruct AppEngine to create Firestore indexes not Datastore indexes?

CodePudding user response:

For composite indexes in Firestore (native mode) you can use the gcloud cli or the cloud console.

If you would like to check in your indexes into a configuration file, you can also use Terraform.

  • Related