IndexingPolicy Class

Definition

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

public class IndexingPolicy extends JsonSerializable
Inheritance
java.lang.Object
Serializable
IndexingPolicy

Inherited Members

Constructors

IndexingPolicy()

Constructor.

IndexingPolicy(Index[] defaultIndexOverrides)

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

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);
    

IndexingPolicy(JSONObject jsonObject)

Constructor.

IndexingPolicy(String jsonString)

Constructor.

Methods

getAutomatic()

Gets whether automatic indexing is enabled for a collection.

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

getExcludedPaths()

Gets the paths that are not indexed.

getIncludedPaths()

Gets the paths that are chosen to be indexed by the user.

getIndexingMode()

Gets the indexing mode (consistent or lazy).

setAutomatic(boolean automatic)

Sets whether automatic indexing is enabled for a collection.

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

setExcludedPaths(Collection<ExcludedPath> excludedPaths)
setIncludedPaths(Collection<IncludedPath> includedPaths)
setIndexingMode(IndexingMode indexingMode)

Sets the indexing mode (consistent or lazy).

Applies to