Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Database 如何在Firestore索引配置文件中添加单字段豁免_Database_Firebase_Indexing_Google Cloud Firestore - Fatal编程技术网

Database 如何在Firestore索引配置文件中添加单字段豁免

Database 如何在Firestore索引配置文件中添加单字段豁免,database,firebase,indexing,google-cloud-firestore,Database,Firebase,Indexing,Google Cloud Firestore,请告诉我如何在firebase-indexes.json文件中为单个字段添加索引豁免,以便通过CLI进行部署 目前,下面是我在文件firebase-indexes.json中的索引配置,可以通过CLI部署,但它正在创建复合类型的索引,而不是作为单个字段 { "indexes": [ { "collectionGroup": "comments", "queryScope": "COLLECTION", "fields": [ {

请告诉我如何在firebase-indexes.json文件中为单个字段添加索引豁免,以便通过CLI进行部署

目前,下面是我在文件firebase-indexes.json中的索引配置,可以通过CLI部署,但它正在创建复合类型的索引,而不是作为单个字段

{
  "indexes": [
    {
      "collectionGroup": "comments",
      "queryScope": "COLLECTION",
      "fields": [
        {
          "fieldPath": "id",
          "order": "ASCENDING"
        },
        {
          "fieldPath": "id",
          "order": "DESCENDING"
        }
      ]
    }
  ]
}

提前感谢。

假设您的集合名为comments,您的豁免字段名为field,您将向firestore.indexes.json添加一个名为fieldOverrides的新属性,如下所示:

{
  "indexes": [
    // your indexes here
  ],
  "fieldOverrides": [
    {
      "collectionGroup": "comments",
      "fieldPath": "field",
      "indexes": [
        {
          "order": "ASCENDING",
          "queryScope": "COLLECTION"
        },
        {
          "order": "DESCENDING",
          "queryScope": "COLLECTION"
        },
        {
          "arrayConfig": "CONTAINS",
          "queryScope": "COLLECTION"
        },
        {
          "order": "ASCENDING",
          "queryScope": "COLLECTION_GROUP"
        },
        {
          "order": "DESCENDING",
          "queryScope": "COLLECTION_GROUP"
        },
        {
          "arrayConfig": "CONTAINS",
          "queryScope": "COLLECTION_GROUP"
        }
      ]
    }
  ]
}

谢谢,但它仅在集合范围内启用,但我希望在集合组范围内启用它,以便可以运行集合组查询,如:fdb.collectionGroup'comments'。where'id',in',[].get。然后{..}。目前,此查询失败。好的,在您的问题中说明这一点会很有帮助。编辑了答案。