你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
IndexingPolicy 类
- java.
lang. Object - JsonSerializable
- com.
microsoft. azure. cosmosdb. IndexingPolicy
- com.
public class IndexingPolicy extends JsonSerializable
表示 Azure Cosmos DB 数据库服务中集合的索引策略配置。
构造函数摘要
构造函数 | 说明 |
---|---|
IndexingPolicy() |
构造函数。 |
IndexingPolicy(Index[] defaultIndexOverrides) |
使用指定的索引集作为根路径的默认索引规范初始化 IndexingPolicy 类的新实例。 以下示例演示如何替代根路径的默认 indexingPolicy:
如果只想替代 Numbers 的 indexingPolicy,可以仅指定以下内容:
|
IndexingPolicy(String jsonString) |
构造函数。 |
方法摘要
修饰符和类型 | 方法和描述 |
---|---|
Boolean |
getAutomatic()
获取是否为集合启用自动索引。 在自动索引中,可以使用 RequestOptions 从索引中显式排除文档。 在手动索引中,可以显式包含文档。 |
Collection<ArrayList<Composite |
getCompositeIndexes()
获取其他索引的复合索引。 |
Collection<Excluded |
getExcludedPaths()
获取未编制索引的路径。 |
Collection<Included |
getIncludedPaths()
获取用户选择要编制索引的路径。 |
Indexing |
getIndexingMode()
获取 (一致或延迟) 的索引模式。 |
Collection<Spatial |
getSpatialIndexes()
设置其他索引的空间索引。 |
void |
setAutomatic(boolean automatic)
设置是否为集合启用自动索引。 在自动索引中,可以使用 RequestOptions 从索引中显式排除文档。 在手动索引中,可以显式包含文档。 |
void |
setCompositeIndexes(Collection<ArrayList<CompositePath>> compositeIndexes)
设置其他索引的复合索引。 |
void | setExcludedPaths(Collection<ExcludedPath> excludedPaths) |
void | setIncludedPaths(Collection<IncludedPath> includedPaths) |
void |
setIndexingMode(IndexingMode indexingMode)
设置索引模式 (一致或延迟) 。 |
void |
setSpatialIndexes(Collection<SpatialSpec> spatialIndexes)
设置其他索引的空间索引。 |
继承成员
构造函数详细信息
IndexingPolicy
public IndexingPolicy()
构造函数。
IndexingPolicy
public IndexingPolicy(Index[] defaultIndexOverrides)
使用指定的索引集作为根路径的默认索引规范初始化 IndexingPolicy 类的新实例。
以下示例演示如何替代根路径的默认 indexingPolicy:
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);
如果只想替代 Numbers 的 indexingPolicy,可以仅指定以下内容:
RangeIndex rangeIndexOverride = Index.Range(DataType.Number, 2);
IndexingPolicy indexingPolicy = new IndexingPolicy(rangeIndexOverride);
参数:
IndexingPolicy
public IndexingPolicy(String jsonString)
构造函数。
参数:
方法详细信息
getAutomatic
public Boolean getAutomatic()
获取是否为集合启用自动索引。
在自动索引中,可以使用 RequestOptions 从索引中显式排除文档。 在手动索引中,可以显式包含文档。
返回:
getCompositeIndexes
public Collection
获取其他索引的复合索引。
返回:
getExcludedPaths
public Collection
获取未编制索引的路径。
返回:
getIncludedPaths
public Collection
获取用户选择要编制索引的路径。
返回:
getIndexingMode
public IndexingMode getIndexingMode()
获取 (一致或延迟) 的索引模式。
返回:
getSpatialIndexes
public Collection
设置其他索引的空间索引。
返回:
setAutomatic
public void setAutomatic(boolean automatic)
设置是否为集合启用自动索引。
在自动索引中,可以使用 RequestOptions 从索引中显式排除文档。 在手动索引中,可以显式包含文档。
参数:
setCompositeIndexes
public void setCompositeIndexes(Collection
设置其他索引的复合索引。
参数:
setExcludedPaths
public void setExcludedPaths(Collection
参数:
setIncludedPaths
public void setIncludedPaths(Collection
参数:
setIndexingMode
public void setIndexingMode(IndexingMode indexingMode)
设置索引模式 (一致或延迟) 。
参数:
setSpatialIndexes
public void setSpatialIndexes(Collection
设置其他索引的空间索引。
参数: