Partager via


IndexingPolicy Class

public final class IndexingPolicy
extends JsonSerializable

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

Constructor Summary

Constructor Description
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.

IndexingPolicy(String jsonString)

Constructor.

IndexingPolicy(JSONObject jsonObject)

Constructor.

Method Summary

Modifier and Type Method and Description
java.lang.Boolean getAutomatic()

Gets whether automatic indexing is enabled for a collection.

java.util.Collection<java.util.ArrayList<CompositePath>> getCompositeIndexes()

Gets the composite indexes for additional indexes.

java.util.Collection<ExcludedPath> getExcludedPaths()

Gets the paths that are not indexed.

java.util.Collection<IncludedPath> getIncludedPaths()

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

IndexingMode getIndexingMode()

Gets the indexing mode (consistent or lazy).

java.util.Collection<SpatialSpec> getSpatialIndexes()

Sets the spatial indexes for additional indexes.

void setAutomatic(boolean automatic)

Sets whether automatic indexing is enabled for a collection.

void setCompositeIndexes(Collection<ArrayList<CompositePath>> compositeIndexes)

Sets the composite indexes for additional indexes.

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

Sets the indexing mode (consistent or lazy).

void setSpatialIndexes(Collection<SpatialSpec> spatialIndexes)

Sets the spatial indexes for additional indexes.

Methods inherited from JsonSerializable

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

IndexingPolicy

public IndexingPolicy()

Constructor.

IndexingPolicy

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

Parameters:

defaultIndexOverrides - comma separated set of indexes that serve as default index specifications for the root path.

IndexingPolicy

public IndexingPolicy(String jsonString)

Constructor.

Parameters:

jsonString - the json string that represents the indexing policy.

IndexingPolicy

public IndexingPolicy(JSONObject jsonObject)

Constructor.

Parameters:

jsonObject - the json object that represents the indexing policy.

Method Details

getAutomatic

public Boolean 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.

Returns:

the automatic

getCompositeIndexes

public Collection> getCompositeIndexes()

Gets the composite indexes for additional indexes.

Returns:

the composite indexes.

getExcludedPaths

public Collection getExcludedPaths()

Gets the paths that are not indexed.

Returns:

the excluded paths.

getIncludedPaths

public Collection getIncludedPaths()

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

Returns:

the included paths.

getIndexingMode

public IndexingMode getIndexingMode()

Gets the indexing mode (consistent or lazy).

Returns:

the indexing mode.

getSpatialIndexes

public Collection getSpatialIndexes()

Sets the spatial indexes for additional indexes.

Returns:

the spatial indexes.

setAutomatic

public void 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.

Parameters:

automatic - the automatic

setCompositeIndexes

public void setCompositeIndexes(Collection> compositeIndexes)

Sets the composite indexes for additional indexes.

Parameters:

compositeIndexes - the composite indexes.

setExcludedPaths

public void setExcludedPaths(Collection excludedPaths)

Parameters:

excludedPaths

setIncludedPaths

public void setIncludedPaths(Collection includedPaths)

Parameters:

includedPaths

setIndexingMode

public void setIndexingMode(IndexingMode indexingMode)

Sets the indexing mode (consistent or lazy).

Parameters:

indexingMode - the indexing mode.

setSpatialIndexes

public void setSpatialIndexes(Collection spatialIndexes)

Sets the spatial indexes for additional indexes.

Parameters:

spatialIndexes - the spatial indexes.

Applies to