Class CosmosGlobalSecondaryIndexDefinition

java.lang.Object
com.azure.cosmos.models.CosmosGlobalSecondaryIndexDefinition

@Beta(value=V4_81_0, warningText="Preview API - subject to change in non-backwards compatible way") public final class CosmosGlobalSecondaryIndexDefinition extends Object
Represents the global secondary index definition for a container in the Azure Cosmos DB service. A global secondary index is derived from a source container and is defined by a SQL-like query. Once created, the source container id and the query definition are immutable for the lifetime of the global secondary index.

Example:


 CosmosGlobalSecondaryIndexDefinition definition =
     new CosmosGlobalSecondaryIndexDefinition("gsi-src", "SELECT c.customerId, c.emailAddress FROM c");
 
  • Constructor Details

    • CosmosGlobalSecondaryIndexDefinition

      @Beta(value=V4_81_0, warningText="Preview API - subject to change in non-backwards compatible way") public CosmosGlobalSecondaryIndexDefinition(String sourceContainerId, String definition)
      Creates a new global secondary index definition. The source container id and the query definition are immutable once the definition is created.
      Parameters:
      sourceContainerId - the id of the source container from which this global secondary index is derived. The SDK will automatically resolve this container id to its resource id (RID) during container creation.
      definition - the SQL-like query definition (e.g. "SELECT c.customerId, c.emailAddress FROM c").
      Throws:
      IllegalArgumentException - if sourceContainerId or definition is null or empty.
  • Method Details

    • getSourceContainerId

      @Beta(value=V4_81_0, warningText="Preview API - subject to change in non-backwards compatible way") public String getSourceContainerId()
      Gets the source container id for the global secondary index.
      Returns:
      the source container id.
    • getSourceContainerRid

      @Beta(value=V4_81_0, warningText="Preview API - subject to change in non-backwards compatible way") public String getSourceContainerRid()
      Gets the source container resource id (RID) for the GlobalSecondaryIndex as returned by the server. This is a read-only field populated from server responses.
      Returns:
      the source container resource id.
    • getStatus

      @Beta(value=V4_81_0, warningText="Preview API - subject to change in non-backwards compatible way") public CosmosGlobalSecondaryIndexBuildStatus getStatus()
      Gets the build status of the GlobalSecondaryIndex as returned by the server. This is a read-only field populated from server responses. Returns null when the status field is absent from the server response. When the server returns a value this SDK version does not declare as a known constant, the returned instance still preserves the original wire value via ExpandableStringEnum.toString().
      Returns:
      the GlobalSecondaryIndex build status, or null if the server did not return one.
    • getDefinition

      @Beta(value=V4_81_0, warningText="Preview API - subject to change in non-backwards compatible way") public String getDefinition()
      Gets the query definition for the GlobalSecondaryIndex.
      Returns:
      the query definition.
    • toString

      public String toString()
      Overrides:
      toString in class Object