Table of Contents

Class Index

Namespace
Microsoft.Azure.Documents
Assembly
Microsoft.Azure.Documents.Client.dll

Base class for IndexingPolicy Indexes in the Azure Cosmos DB service, you should use a concrete Index like HashIndex or RangeIndex.

public abstract class Index : JsonSerializable
Inheritance
Index
Derived
Inherited Members
Extension Methods

Constructors

Index(IndexKind)

Initializes a new instance of the Index class for the Azure Cosmos DB service.

protected Index(IndexKind kind)

Parameters

kind IndexKind

Properties

Kind

Gets or sets the kind of indexing to be applied in the Azure Cosmos DB service.

public IndexKind Kind { get; }

Property Value

IndexKind

One of the values of the IndexKind enumeration.

Methods

Hash(DataType)

Returns an instance of the HashIndex class with specified DataType for the Azure Cosmos DB service.

public static HashIndex Hash(DataType dataType)

Parameters

dataType DataType

Specifies the target data type for the index path specification.

Returns

HashIndex

An instance of HashIndex type.

Examples

Here is an example to create HashIndex instance passing in the DataType:

HashIndex hashIndex = Index.Hash(DataType.String);
See Also

Hash(DataType, short)

Returns an instance of the HashIndex class with specified DataType and precision for the Azure Cosmos DB service.

public static HashIndex Hash(DataType dataType, short precision)

Parameters

dataType DataType

Specifies the target data type for the index path specification.

precision short

Specifies the precision to be used for the data type associated with this index.

Returns

HashIndex

An instance of HashIndex type.

Examples

Here is an example to create HashIndex instance passing in the DataType and precision:

HashIndex hashIndex = Index.Hash(DataType.String, 3);
See Also

Range(DataType)

Returns an instance of the RangeIndex class with specified DataType for the Azure Cosmos DB service.

public static RangeIndex Range(DataType dataType)

Parameters

dataType DataType

Specifies the target data type for the index path specification.

Returns

RangeIndex

An instance of RangeIndex type.

Examples

Here is an example to create RangeIndex instance passing in the DataType:

RangeIndex rangeIndex = Index.Range(DataType.Number);
See Also

Range(DataType, short)

Returns an instance of the RangeIndex class with specified DataType and precision for the Azure Cosmos DB service.

public static RangeIndex Range(DataType dataType, short precision)

Parameters

dataType DataType

Specifies the target data type for the index path specification.

precision short

Specifies the precision to be used for the data type associated with this index.

Returns

RangeIndex

An instance of RangeIndex type.

Examples

Here is an example to create RangeIndex instance passing in the DataType and precision:

RangeIndex rangeIndex = Index.Range(DataType.Number, -1);
See Also

Spatial(DataType)

Returns an instance of the SpatialIndex class with specified DataType for the Azure Cosmos DB service.

public static SpatialIndex Spatial(DataType dataType)

Parameters

dataType DataType

Specifies the target data type for the index path specification.

Returns

SpatialIndex

An instance of SpatialIndex type.

Examples

Here is an example to create SpatialIndex instance passing in the DataType:

SpatialIndex spatialIndex = Index.Spatial(DataType.Point);
See Also