Index Args
Cloud Firestore indexes enable simple and complex queries against documents in a database. Both Firestore Native and Datastore Mode indexes are supported. This resource manages composite indexes and not single field indexes. To manage single field indexes, use the gcp.firestore.Field
resource instead. To get more information about Index, see:
How-to Guides
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
gcp.firestore.Database
resource andlocation_id
set to your chosen location. If you wish to use App Engine, you may instead create agcp.appengine.Application
resource. Your Firestore location will be the same as the App Engine location specified.
Example Usage
Firestore Index Basic
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const database = new gcp.firestore.Database("database", {
project: "my-project-name",
name: "database-id",
locationId: "nam5",
type: "FIRESTORE_NATIVE",
deleteProtectionState: "DELETE_PROTECTION_DISABLED",
deletionPolicy: "DELETE",
});
const my_index = new gcp.firestore.Index("my-index", {
project: "my-project-name",
database: database.name,
collection: "atestcollection",
fields: [
{
fieldPath: "name",
order: "ASCENDING",
},
{
fieldPath: "description",
order: "DESCENDING",
},
],
});
import pulumi
import pulumi_gcp as gcp
database = gcp.firestore.Database("database",
project="my-project-name",
name="database-id",
location_id="nam5",
type="FIRESTORE_NATIVE",
delete_protection_state="DELETE_PROTECTION_DISABLED",
deletion_policy="DELETE")
my_index = gcp.firestore.Index("my-index",
project="my-project-name",
database=database.name,
collection="atestcollection",
fields=[
{
"field_path": "name",
"order": "ASCENDING",
},
{
"field_path": "description",
"order": "DESCENDING",
},
])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var database = new Gcp.Firestore.Database("database", new()
{
Project = "my-project-name",
Name = "database-id",
LocationId = "nam5",
Type = "FIRESTORE_NATIVE",
DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
DeletionPolicy = "DELETE",
});
var my_index = new Gcp.Firestore.Index("my-index", new()
{
Project = "my-project-name",
Database = database.Name,
Collection = "atestcollection",
Fields = new[]
{
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "name",
Order = "ASCENDING",
},
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "description",
Order = "DESCENDING",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
Project: pulumi.String("my-project-name"),
Name: pulumi.String("database-id"),
LocationId: pulumi.String("nam5"),
Type: pulumi.String("FIRESTORE_NATIVE"),
DeleteProtectionState: pulumi.String("DELETE_PROTECTION_DISABLED"),
DeletionPolicy: pulumi.String("DELETE"),
})
if err != nil {
return err
}
_, err = firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
Project: pulumi.String("my-project-name"),
Database: database.Name,
Collection: pulumi.String("atestcollection"),
Fields: firestore.IndexFieldArray{
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("name"),
Order: pulumi.String("ASCENDING"),
},
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("description"),
Order: pulumi.String("DESCENDING"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firestore.Database;
import com.pulumi.gcp.firestore.DatabaseArgs;
import com.pulumi.gcp.firestore.Index;
import com.pulumi.gcp.firestore.IndexArgs;
import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var database = new Database("database", DatabaseArgs.builder()
.project("my-project-name")
.name("database-id")
.locationId("nam5")
.type("FIRESTORE_NATIVE")
.deleteProtectionState("DELETE_PROTECTION_DISABLED")
.deletionPolicy("DELETE")
.build());
var my_index = new Index("my-index", IndexArgs.builder()
.project("my-project-name")
.database(database.name())
.collection("atestcollection")
.fields(
IndexFieldArgs.builder()
.fieldPath("name")
.order("ASCENDING")
.build(),
IndexFieldArgs.builder()
.fieldPath("description")
.order("DESCENDING")
.build())
.build());
}
}
resources:
database:
type: gcp:firestore:Database
properties:
project: my-project-name
name: database-id
locationId: nam5
type: FIRESTORE_NATIVE
deleteProtectionState: DELETE_PROTECTION_DISABLED
deletionPolicy: DELETE
my-index:
type: gcp:firestore:Index
properties:
project: my-project-name
database: ${database.name}
collection: atestcollection
fields:
- fieldPath: name
order: ASCENDING
- fieldPath: description
order: DESCENDING
Firestore Index Datastore Mode
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const database = new gcp.firestore.Database("database", {
project: "my-project-name",
name: "database-id-dm",
locationId: "nam5",
type: "DATASTORE_MODE",
deleteProtectionState: "DELETE_PROTECTION_DISABLED",
deletionPolicy: "DELETE",
});
const my_index = new gcp.firestore.Index("my-index", {
project: "my-project-name",
database: database.name,
collection: "atestcollection",
queryScope: "COLLECTION_RECURSIVE",
apiScope: "DATASTORE_MODE_API",
fields: [
{
fieldPath: "name",
order: "ASCENDING",
},
{
fieldPath: "description",
order: "DESCENDING",
},
],
});
import pulumi
import pulumi_gcp as gcp
database = gcp.firestore.Database("database",
project="my-project-name",
name="database-id-dm",
location_id="nam5",
type="DATASTORE_MODE",
delete_protection_state="DELETE_PROTECTION_DISABLED",
deletion_policy="DELETE")
my_index = gcp.firestore.Index("my-index",
project="my-project-name",
database=database.name,
collection="atestcollection",
query_scope="COLLECTION_RECURSIVE",
api_scope="DATASTORE_MODE_API",
fields=[
{
"field_path": "name",
"order": "ASCENDING",
},
{
"field_path": "description",
"order": "DESCENDING",
},
])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var database = new Gcp.Firestore.Database("database", new()
{
Project = "my-project-name",
Name = "database-id-dm",
LocationId = "nam5",
Type = "DATASTORE_MODE",
DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
DeletionPolicy = "DELETE",
});
var my_index = new Gcp.Firestore.Index("my-index", new()
{
Project = "my-project-name",
Database = database.Name,
Collection = "atestcollection",
QueryScope = "COLLECTION_RECURSIVE",
ApiScope = "DATASTORE_MODE_API",
Fields = new[]
{
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "name",
Order = "ASCENDING",
},
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "description",
Order = "DESCENDING",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
Project: pulumi.String("my-project-name"),
Name: pulumi.String("database-id-dm"),
LocationId: pulumi.String("nam5"),
Type: pulumi.String("DATASTORE_MODE"),
DeleteProtectionState: pulumi.String("DELETE_PROTECTION_DISABLED"),
DeletionPolicy: pulumi.String("DELETE"),
})
if err != nil {
return err
}
_, err = firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
Project: pulumi.String("my-project-name"),
Database: database.Name,
Collection: pulumi.String("atestcollection"),
QueryScope: pulumi.String("COLLECTION_RECURSIVE"),
ApiScope: pulumi.String("DATASTORE_MODE_API"),
Fields: firestore.IndexFieldArray{
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("name"),
Order: pulumi.String("ASCENDING"),
},
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("description"),
Order: pulumi.String("DESCENDING"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firestore.Database;
import com.pulumi.gcp.firestore.DatabaseArgs;
import com.pulumi.gcp.firestore.Index;
import com.pulumi.gcp.firestore.IndexArgs;
import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var database = new Database("database", DatabaseArgs.builder()
.project("my-project-name")
.name("database-id-dm")
.locationId("nam5")
.type("DATASTORE_MODE")
.deleteProtectionState("DELETE_PROTECTION_DISABLED")
.deletionPolicy("DELETE")
.build());
var my_index = new Index("my-index", IndexArgs.builder()
.project("my-project-name")
.database(database.name())
.collection("atestcollection")
.queryScope("COLLECTION_RECURSIVE")
.apiScope("DATASTORE_MODE_API")
.fields(
IndexFieldArgs.builder()
.fieldPath("name")
.order("ASCENDING")
.build(),
IndexFieldArgs.builder()
.fieldPath("description")
.order("DESCENDING")
.build())
.build());
}
}
resources:
database:
type: gcp:firestore:Database
properties:
project: my-project-name
name: database-id-dm
locationId: nam5
type: DATASTORE_MODE
deleteProtectionState: DELETE_PROTECTION_DISABLED
deletionPolicy: DELETE
my-index:
type: gcp:firestore:Index
properties:
project: my-project-name
database: ${database.name}
collection: atestcollection
queryScope: COLLECTION_RECURSIVE
apiScope: DATASTORE_MODE_API
fields:
- fieldPath: name
order: ASCENDING
- fieldPath: description
order: DESCENDING
Firestore Index Vector
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const database = new gcp.firestore.Database("database", {
project: "my-project-name",
name: "database-id-vector",
locationId: "nam5",
type: "FIRESTORE_NATIVE",
deleteProtectionState: "DELETE_PROTECTION_DISABLED",
deletionPolicy: "DELETE",
});
const my_index = new gcp.firestore.Index("my-index", {
project: "my-project-name",
database: database.name,
collection: "atestcollection",
fields: [
{
fieldPath: "field_name",
order: "ASCENDING",
},
{
fieldPath: "__name__",
order: "ASCENDING",
},
{
fieldPath: "description",
vectorConfig: {
dimension: 128,
flat: {},
},
},
],
});
import pulumi
import pulumi_gcp as gcp
database = gcp.firestore.Database("database",
project="my-project-name",
name="database-id-vector",
location_id="nam5",
type="FIRESTORE_NATIVE",
delete_protection_state="DELETE_PROTECTION_DISABLED",
deletion_policy="DELETE")
my_index = gcp.firestore.Index("my-index",
project="my-project-name",
database=database.name,
collection="atestcollection",
fields=[
{
"field_path": "field_name",
"order": "ASCENDING",
},
{
"field_path": "__name__",
"order": "ASCENDING",
},
{
"field_path": "description",
"vector_config": {
"dimension": 128,
"flat": {},
},
},
])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var database = new Gcp.Firestore.Database("database", new()
{
Project = "my-project-name",
Name = "database-id-vector",
LocationId = "nam5",
Type = "FIRESTORE_NATIVE",
DeleteProtectionState = "DELETE_PROTECTION_DISABLED",
DeletionPolicy = "DELETE",
});
var my_index = new Gcp.Firestore.Index("my-index", new()
{
Project = "my-project-name",
Database = database.Name,
Collection = "atestcollection",
Fields = new[]
{
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "field_name",
Order = "ASCENDING",
},
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "__name__",
Order = "ASCENDING",
},
new Gcp.Firestore.Inputs.IndexFieldArgs
{
FieldPath = "description",
VectorConfig = new Gcp.Firestore.Inputs.IndexFieldVectorConfigArgs
{
Dimension = 128,
Flat = null,
},
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/firestore"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
database, err := firestore.NewDatabase(ctx, "database", &firestore.DatabaseArgs{
Project: pulumi.String("my-project-name"),
Name: pulumi.String("database-id-vector"),
LocationId: pulumi.String("nam5"),
Type: pulumi.String("FIRESTORE_NATIVE"),
DeleteProtectionState: pulumi.String("DELETE_PROTECTION_DISABLED"),
DeletionPolicy: pulumi.String("DELETE"),
})
if err != nil {
return err
}
_, err = firestore.NewIndex(ctx, "my-index", &firestore.IndexArgs{
Project: pulumi.String("my-project-name"),
Database: database.Name,
Collection: pulumi.String("atestcollection"),
Fields: firestore.IndexFieldArray{
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("field_name"),
Order: pulumi.String("ASCENDING"),
},
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("__name__"),
Order: pulumi.String("ASCENDING"),
},
&firestore.IndexFieldArgs{
FieldPath: pulumi.String("description"),
VectorConfig: &firestore.IndexFieldVectorConfigArgs{
Dimension: pulumi.Int(128),
Flat: nil,
},
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.firestore.Database;
import com.pulumi.gcp.firestore.DatabaseArgs;
import com.pulumi.gcp.firestore.Index;
import com.pulumi.gcp.firestore.IndexArgs;
import com.pulumi.gcp.firestore.inputs.IndexFieldArgs;
import com.pulumi.gcp.firestore.inputs.IndexFieldVectorConfigArgs;
import com.pulumi.gcp.firestore.inputs.IndexFieldVectorConfigFlatArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var database = new Database("database", DatabaseArgs.builder()
.project("my-project-name")
.name("database-id-vector")
.locationId("nam5")
.type("FIRESTORE_NATIVE")
.deleteProtectionState("DELETE_PROTECTION_DISABLED")
.deletionPolicy("DELETE")
.build());
var my_index = new Index("my-index", IndexArgs.builder()
.project("my-project-name")
.database(database.name())
.collection("atestcollection")
.fields(
IndexFieldArgs.builder()
.fieldPath("field_name")
.order("ASCENDING")
.build(),
IndexFieldArgs.builder()
.fieldPath("__name__")
.order("ASCENDING")
.build(),
IndexFieldArgs.builder()
.fieldPath("description")
.vectorConfig(IndexFieldVectorConfigArgs.builder()
.dimension(128)
.flat()
.build())
.build())
.build());
}
}
resources:
database:
type: gcp:firestore:Database
properties:
project: my-project-name
name: database-id-vector
locationId: nam5
type: FIRESTORE_NATIVE
deleteProtectionState: DELETE_PROTECTION_DISABLED
deletionPolicy: DELETE
my-index:
type: gcp:firestore:Index
properties:
project: my-project-name
database: ${database.name}
collection: atestcollection
fields:
- fieldPath: field_name
order: ASCENDING
- fieldPath: __name__
order: ASCENDING
- fieldPath: description
vectorConfig:
dimension: 128
flat: {}
Import
Index can be imported using any of these accepted formats:
{{name}}
When using thepulumi import
command, Index can be imported using one of the formats above. For example:
$ pulumi import gcp:firestore/index:Index default {{name}}
Constructors
Properties
The collection being indexed.
The fields supported by this index. The last non-stored field entry is always for the field path __name__
. 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, the __name__
will be ordered "ASCENDING"
(unless explicitly specified otherwise). Structure is documented below.
The scope at which a query is run. Default value: "COLLECTION" Possible values: "COLLECTION", "COLLECTION_GROUP", "COLLECTION_RECURSIVE"