CosmosGlobalSecondaryIndexDefinition Class

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

public final class CosmosGlobalSecondaryIndexDefinition

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 Summary

Constructor Description
CosmosGlobalSecondaryIndexDefinition(String sourceContainerId, String definition)

Creates a new global secondary index definition.

Method Summary

Modifier and Type Method and Description
String getDefinition()

Gets the query definition for the GlobalSecondaryIndex.

String getSourceContainerId()

Gets the source container id for the global secondary index.

String getSourceContainerRid()

Gets the source container resource id (RID) for the GlobalSecondaryIndex as returned by the server.

CosmosGlobalSecondaryIndexBuildStatus getStatus()

Gets the build status of the GlobalSecondaryIndex as returned by the server.

String toString()

Methods inherited from java.lang.Object

Constructor Details

CosmosGlobalSecondaryIndexDefinition

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").

Method Details

getDefinition

public String getDefinition()

Gets the query definition for the GlobalSecondaryIndex.

Returns:

the query definition.

getSourceContainerId

public String getSourceContainerId()

Gets the source container id for the global secondary index.

Returns:

the source container id.

getSourceContainerRid

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

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 CosmosGlobalSecondaryIndexBuildStatus#toString().

Returns:

the GlobalSecondaryIndex build status, or null if the server did not return one.

toString

public String toString()

Overrides:

CosmosGlobalSecondaryIndexDefinition.toString()

Applies to