Please let me know how to add Index exemptions for Single-field, in the firebase-indexes.json file, in order to deploy through CLI.
Currently, below is my index config in the file firebase-indexes.json, able to deploy through CLI, but it is creating an index of type Composite, not as a Single-field Exemption.
{
"indexes": [
{
"collectionGroup": "comments",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "id",
"order": "ASCENDING"
},
{
"fieldPath": "id",
"order": "DESCENDING"
}
]
}
]
}
Thanks in advance.
Assuming that your collection is called "comments" and your exemption field is called "field", you will add a new property to your firestore.indexes.json called "fieldOverrides", like this:
{
"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"
}
]
}
]
}