Class Index


  • public class Index
    extends com.pulumi.resources.CustomResource
    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](https://cloud.google.com/firestore/docs/reference/rest/v1/projects.databases.collectionGroups.indexes) * How-to Guides * [Official Documentation](https://cloud.google.com/firestore/docs/query-data/indexing) > **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 and `location_id` set to your chosen location. If you wish to use App Engine, you may instead create a `gcp.appengine.Application` resource with `database_type` set to `"CLOUD_FIRESTORE"`. Your Firestore location will be the same as the App Engine location specified. ## Example Usage ### Firestore Index Basic <!--Start PulumiCodeChooser --> ```java 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()); } } ``` <!--End PulumiCodeChooser --> ### Firestore Index Datastore Mode <!--Start PulumiCodeChooser --> ```java 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()); } } ``` <!--End PulumiCodeChooser --> ### Firestore Index Vector <!--Start PulumiCodeChooser --> ```java 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()); } } ``` <!--End PulumiCodeChooser --> ## Import Index can be imported using any of these accepted formats: * `{{name}}` When using the `pulumi import` command, Index can be imported using one of the formats above. For example: ```sh $ pulumi import gcp:firestore/index:Index default {{name}} ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      Index​(java.lang.String name)  
      Index​(java.lang.String name, IndexArgs args)  
      Index​(java.lang.String name, IndexArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> apiScope()  
      com.pulumi.core.Output<java.lang.String> collection()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> database()  
      com.pulumi.core.Output<java.util.List<IndexField>> fields()  
      static Index get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, IndexState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.lang.String> name()  
      com.pulumi.core.Output<java.lang.String> project()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> queryScope()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Index

        public Index​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • Index

        public Index​(java.lang.String name,
                     IndexArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • Index

        public Index​(java.lang.String name,
                     IndexArgs args,
                     @Nullable
                     com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • apiScope

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> apiScope()
        Returns:
        The API scope at which a query is run. Default value: "ANY_API" Possible values: ["ANY_API", "DATASTORE_MODE_API"]
      • collection

        public com.pulumi.core.Output<java.lang.String> collection()
        Returns:
        The collection being indexed.
      • database

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> database()
        Returns:
        The Firestore database id. Defaults to '"(default)"'.
      • fields

        public com.pulumi.core.Output<java.util.List<IndexField>> fields()
        Returns:
        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.
      • name

        public com.pulumi.core.Output<java.lang.String> name()
        Returns:
        A server defined name for this index. Format: `projects/{{project}}/databases/{{database}}/collectionGroups/{{collection}}/indexes/{{server_generated_id}}`
      • project

        public com.pulumi.core.Output<java.lang.String> project()
      • queryScope

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> queryScope()
        Returns:
        The scope at which a query is run. Default value: "COLLECTION" Possible values: ["COLLECTION", "COLLECTION_GROUP", "COLLECTION_RECURSIVE"]
      • get

        public static Index get​(java.lang.String name,
                                com.pulumi.core.Output<java.lang.String> id,
                                @Nullable
                                IndexState state,
                                @Nullable
                                com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.