你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Index 类

public class Index extends JsonSerializable

表示 Azure Cosmos DB 数据库服务中集合的索引。

构造函数摘要

构造函数 说明
Index(IndexKind indexKind)

构造函数。

Index(String jsonString, IndexKind indexKind)

构造函数。

方法摘要

修饰符和类型 方法和描述
IndexKind getKind()

获取索引类型。

HashIndex Hash(DataType dataType)

返回具有指定 DataType 的 HashIndex 类的实例。

下面是创建传入 DataType 的 HashIndex 实例的示例:

              
              HashIndex hashIndex = Index.Hash (DataType.String) ;
</code></pre></p>

HashIndex Hash(DataType dataType, int precision)

返回具有指定数据类型和精度的 HashIndex 类的实例。

下面是创建传入 DataType 和精度的 HashIndex 实例的示例:

HashIndex hashIndex = Index.Hash (DataType.String, 3) ;

RangeIndex Range(DataType dataType)

返回具有指定 DataType 的 RangeIndex 类的实例。

下面是创建传入 DataType 的 RangeIndex 实例的示例:

              
              RangeIndex rangeIndex = Index.Range (DataType.Number) ;
</code></pre></p>

RangeIndex Range(DataType dataType, int precision)

返回具有指定 DataType 和精度的 RangeIndex 类的实例。

下面是创建 RangeIndex 实例的示例,该实例传入 DataType 和精度:

              
              RangeIndex rangeIndex = Index.Range (DataType.Number, -1) ;
</code></pre></p>

SpatialIndex Spatial(DataType dataType)

返回具有指定 DataType 的 SpatialIndex 类的实例。

下面是创建传入 DataType 的 SpatialIndex 实例的示例:

SpatialIndex spatialIndex = Index.Spatial (DataType.Point) ;

继承成员

构造函数详细信息

Index

protected Index(IndexKind indexKind)

构造函数。

参数:

indexKind - 索引的种类

Index

protected Index(String jsonString, IndexKind indexKind)

构造函数。

参数:

jsonString - 表示索引的 json 字符串。
indexKind - 索引的种类

方法详细信息

getKind

public IndexKind getKind()

获取索引类型。

返回:

索引类型。

Hash

public static HashIndex Hash(DataType dataType)

返回具有指定 DataType 的 HashIndex 类的实例。

下面是创建传入 DataType 的 HashIndex 实例的示例:

              
              HashIndex hashIndex = Index.Hash (DataType.String) ;
</code></pre></p>

参数:

dataType - 指定索引路径规范的目标数据类型。

返回:

HashIndex 类型的实例。

Hash

public static HashIndex Hash(DataType dataType, int precision)

返回具有指定数据类型和精度的 HashIndex 类的实例。

下面是创建传入 DataType 和精度的 HashIndex 实例的示例:

HashIndex hashIndex = Index.Hash (DataType.String, 3) ;

参数:

dataType - 指定索引路径规范的目标数据类型。
precision - 指定要用于与此索引关联的数据类型的精度。

返回:

HashIndex 类型的实例。

Range

public static RangeIndex Range(DataType dataType)

返回具有指定 DataType 的 RangeIndex 类的实例。

下面是创建传入 DataType 的 RangeIndex 实例的示例:

              
              RangeIndex rangeIndex = Index.Range (DataType.Number) ;
</code></pre></p>

参数:

dataType - 数据类型。

返回:

RangeIndex 类型的实例。

Range

public static RangeIndex Range(DataType dataType, int precision)

返回具有指定 DataType 和精度的 RangeIndex 类的实例。

下面是创建 RangeIndex 实例的示例,该实例传入 DataType 和精度:

              
              RangeIndex rangeIndex = Index.Range (DataType.Number, -1) ;
</code></pre></p>

参数:

dataType - 指定索引路径规范的目标数据类型。
precision - 指定要用于与此索引关联的数据类型的精度。

返回:

RangeIndex 类型的实例。

Spatial

public static SpatialIndex Spatial(DataType dataType)

返回具有指定 DataType 的 SpatialIndex 类的实例。

下面是创建传入 DataType 的 SpatialIndex 实例的示例:

SpatialIndex spatialIndex = Index.Spatial (DataType.Point) ;

参数:

dataType - 指定索引路径规范的目标数据类型。

返回:

SpatialIndex 类型的实例。

适用于