在原生模式下在 AppEngine + Firestore 中创建复合索引

Create composite index in AppEngine + Firestore in Native Mode

我们目前正在以原生模式使用 Cloud Firestore 开发 AppEngine 标准应用程序,该应用程序运行良好。 现在,我们想要支持一个需要复合索引的查询,我们尝试使用 index.yaml 文件创建:

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

使用 gcloud app deploy index.yaml 进行测试时,我们观察到正在创建索引。但是,创建的索引是 Cloud Datastore 索引而不是 Cloud Firestore 索引,即使 Datastore“甚至没有启用”(如果您尝试访问 Datastore 视图,Cloud 控制台希望直接将您发送到 Firestore 视图)。 因此,我们的查询失败了。 我们如何指示 AppEngine 创建 Firestore 索引而不是 Datastore 索引?

对于 Firestore 中的复合索引(本机模式),您可以使用 gcloud cli or the cloud console

如果您想将索引签入配置文件,也可以使用 Terraform