Table of Contents

Class IndexingPolicy

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

Represents the indexing policy configuration for a collection in the Azure Cosmos DB service.

public sealed class IndexingPolicy : JsonSerializable, ICloneable
Inheritance
IndexingPolicy
Implements
Inherited Members
Extension Methods

Remarks

Indexing policies can used to configure which properties (JSON paths) are included/excluded, whether the index is updated consistently or offline (lazy), automatic vs. opt-in per-document, as well as the precision and type of index per path.

Refer to http://azure.microsoft.com/documentation/articles/documentdb-indexing-policies/ for additional information on how to specify indexing policies.

Constructors

IndexingPolicy()

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

public IndexingPolicy()

Remarks

Indexing mode is set to consistent.

IndexingPolicy(params Index[])

Initializes a new instance of the IndexingPolicy class with the specified set of indexes as default index specifications for the root path for the Azure Cosmos DB service.

public IndexingPolicy(params Index[] defaultIndexOverrides)

Parameters

defaultIndexOverrides Index[]

Comma seperated set of indexes that serve as default index specifications for the root path.

Examples

The following example shows how to override the default indexingPolicy for root path:

HashIndex hashIndexOverride = Index.Hash(DataType.String, 5);
RangeIndex rangeIndexOverride = Index.Range(DataType.Number, 2);
SpatialIndex spatialIndexOverride = Index.Spatial(DataType.Point);

IndexingPolicy indexingPolicy = new IndexingPolicy(hashIndexOverride, rangeIndexOverride, spatialIndexOverride);

If you would like to just override the indexingPolicy for Numbers you can specify just that:

RangeIndex rangeIndexOverride = Index.Range(DataType.Number, 2);

IndexingPolicy indexingPolicy = new IndexingPolicy(rangeIndexOverride);
See Also

Properties

Automatic

Gets or sets a value that indicates whether automatic indexing is enabled for a collection in the Azure Cosmos DB service.

public bool Automatic { get; set; }

Property Value

bool

True, if automatic indexing is enabled; otherwise, false.

Remarks

In automatic indexing, documents can be explicitly excluded from indexing using RequestOptions.
In manual indexing, documents can be explicitly included.

CompositeIndexes

Gets or sets the additonal composite indexes

public Collection<Collection<CompositePath>> CompositeIndexes { get; set; }

Property Value

Collection<Collection<CompositePath>>

Examples

"composite": [ [ { "path": "/joining_year", "order": "ascending" }, { "path": "/level", "order": "descending" } ], [ { "path": "/country" }, { "path": "/city" } ] ]

ExcludedPaths

Gets or sets the collection containing ExcludedPath objects in the Azure Cosmos DB service.

public Collection<ExcludedPath> ExcludedPaths { get; set; }

Property Value

Collection<ExcludedPath>

The collection containing ExcludedPath objects.

IncludedPaths

Gets or sets the collection containing IncludedPath objects in the Azure Cosmos DB service.

public Collection<IncludedPath> IncludedPaths { get; set; }

Property Value

Collection<IncludedPath>

The collection containing IncludedPath objects.

IndexingMode

Gets or sets the indexing mode (consistent or lazy) in the Azure Cosmos DB service.

public IndexingMode IndexingMode { get; set; }

Property Value

IndexingMode

One of the values of the IndexingMode enumeration.

SpatialIndexes

Gets or sets the additonal spatial indexes

public Collection<SpatialSpec> SpatialIndexes { get; set; }

Property Value

Collection<SpatialSpec>

Methods

Clone()

Performs a deep copy of the indexing policy for the Azure Cosmos DB service.

public object Clone()

Returns

object

A clone of the indexing policy.

See Also