Package com.azure.data.cosmos
Class IndexingPolicy
- java.lang.Object
-
- com.azure.data.cosmos.JsonSerializable
-
- com.azure.data.cosmos.IndexingPolicy
-
public final class IndexingPolicy extends JsonSerializable
Represents the indexing policy configuration for a collection in the Azure Cosmos DB database service.
-
-
Constructor Summary
Constructors 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean
automatic()
Gets whether automatic indexing is enabled for a collection.IndexingPolicy
automatic(boolean automatic)
Sets whether automatic indexing is enabled for a collection.List<List<CompositePath>>
compositeIndexes()
Gets the composite indexes for additional indexes.IndexingPolicy
compositeIndexes(List<List<CompositePath>> compositeIndexes)
Sets the composite indexes for additional indexes.List<ExcludedPath>
excludedPaths()
Gets the paths that are not indexed.IndexingPolicy
excludedPaths(List<ExcludedPath> excludedPaths)
List<IncludedPath>
includedPaths()
Gets the paths that are chosen to be indexed by the user.IndexingMode
indexingMode()
Gets the indexing mode (consistent or lazy).IndexingPolicy
indexingMode(IndexingMode indexingMode)
Sets the indexing mode (consistent or lazy).void
setIncludedPaths(List<IncludedPath> includedPaths)
List<SpatialSpec>
spatialIndexes()
Sets the spatial indexes for additional indexes.IndexingPolicy
spatialIndexes(List<SpatialSpec> spatialIndexes)
Sets the spatial indexes for additional indexes.-
Methods inherited from class com.azure.data.cosmos.JsonSerializable
get, getBoolean, getCollection, getDouble, getInt, getList, getLogger, getLong, getMap, getObject, getObjectByPath, getString, has, toJson, toJson, toObject, toString
-
-
-
-
Constructor Detail
-
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.
-
-
Method Detail
-
automatic
public Boolean automatic()
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
-
automatic
public IndexingPolicy automatic(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- Returns:
- the Indexing Policy.
-
indexingMode
public IndexingMode indexingMode()
Gets the indexing mode (consistent or lazy).- Returns:
- the indexing mode.
-
indexingMode
public IndexingPolicy indexingMode(IndexingMode indexingMode)
Sets the indexing mode (consistent or lazy).- Parameters:
indexingMode
- the indexing mode.- Returns:
- the Indexing Policy.
-
includedPaths
public List<IncludedPath> includedPaths()
Gets the paths that are chosen to be indexed by the user.- Returns:
- the included paths.
-
setIncludedPaths
public void setIncludedPaths(List<IncludedPath> includedPaths)
-
excludedPaths
public List<ExcludedPath> excludedPaths()
Gets the paths that are not indexed.- Returns:
- the excluded paths.
-
excludedPaths
public IndexingPolicy excludedPaths(List<ExcludedPath> excludedPaths)
-
compositeIndexes
public List<List<CompositePath>> compositeIndexes()
Gets the composite indexes for additional indexes.- Returns:
- the composite indexes.
-
compositeIndexes
public IndexingPolicy compositeIndexes(List<List<CompositePath>> compositeIndexes)
Sets the composite indexes for additional indexes.- Parameters:
compositeIndexes
- the composite indexes.- Returns:
- the Indexing Policy.
-
spatialIndexes
public List<SpatialSpec> spatialIndexes()
Sets the spatial indexes for additional indexes.- Returns:
- the spatial indexes.
-
spatialIndexes
public IndexingPolicy spatialIndexes(List<SpatialSpec> spatialIndexes)
Sets the spatial indexes for additional indexes.- Parameters:
spatialIndexes
- the spatial indexes.- Returns:
- the Indexing Policy.
-
-