googleFirestoreIndex
Cloud Firestore indexes enable simple and complex queries against documents in a database. This resource manages composite indexes and not single field indexes.
To get more information about Index, see:
- API documentation
- How-to Guides
- Official Documentation
\~> Warning: This resource creates a Firestore Index on a project that already has a Firestore database. If you haven't already created it, you may create a googleFirestoreDatabase
resource with type
set to "firestoreNative"
and locationId
set to your chosen location. If you wish to use App Engine, you may instead create a googleAppEngineApplication
resource with databaseType
set to "cloudFirestore"
. Your Firestore location will be the same as the App Engine location specified.
Example Usage - Firestore Index Basic
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as google from "./.gen/providers/google";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: google.
For a more precise conversion please use the --provider flag in convert.*/
new google.firestoreIndex.FirestoreIndex(this, "my-index", {
collection: "chatrooms",
fields: [
{
field_path: "name",
order: "ASCENDING",
},
{
field_path: "description",
order: "DESCENDING",
},
],
project: "my-project-name",
});
Argument Reference
The following arguments are supported:
-
collection
- (Required) The collection being indexed. -
fields
- (Required) The fields supported by this index. The last field entry is always for the field pathname
. If, on creation,name
was not specified as the last field, it will be added automatically with the same direction as that of the last field defined. If the final field in a composite index is not directional, thename
will be ordered"ascending"
(unless explicitly specified otherwise). Structure is documented below.
-
fieldPath
- (Optional) Name of the field. -
order
- (Optional) Indicates that this field supports ordering by the specified order or comparing using =, <, <=, >, >=. Only one oforder
andarrayConfig
can be specified. Possible values areascending
anddescending
. -
arrayConfig
- (Optional) Indicates that this field supports operations on arrayValues. Only one oforder
andarrayConfig
can be specified. Possible values arecontains
.
-
database
- (Optional) The Firestore database id. Defaults to"(default)"
. -
queryScope
- (Optional) The scope at which a query is run. Default value iscollection
. Possible values arecollection
andcollectionGroup
. -
project
- (Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
Attributes Reference
In addition to the arguments listed above, the following computed attributes are exported:
-
id
- an identifier for the resource with format{{name}}
-
name
- A server defined name for this index. Format:projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{serverGeneratedId}}
Timeouts
This resource provides the following Timeouts configuration options:
create
- Default is 20 minutes.delete
- Default is 20 minutes.
Import
Index can be imported using any of these accepted formats:
User Project Overrides
This resource supports User Project Overrides.