Docs 菜单
Docs 主页
/
MongoDB Atlas
/ / / /

如何为 UUID 字段编制索引以实现高效过滤和排序

在此页面上

  • uuid 类型定义索引
  • 配置 uuid 字段属性

如果需要保证唯一的值,请使用 通用唯一标识符 (UUID)。您可以使用 Atlas Search uuid 类型对 BSON Binary Subtype 4 字段进行索引、查询和排序

要定义 uuid 类型的索引,请在 Atlas UI 中选择您的首选配置方法,然后选择数据库和集合。

  1. 单击 Refine Your Index 配置索引。

  2. Field Mappings 部分中,单击 Add Field 打开 Add Field Mapping 窗口。

  3. 单击 Customized Configuration(连接)。

  4. Field Name 下拉菜单中选择要索引的字段。

  5. 单击 Data Type(添加数据)下拉列表并选择 Uuid(插入文档)。

  6. 单击 Add(连接)。

以下是 uuid 类型的 JSON 语法。将默认索引定义替换为以下内容。要了解有关字段的更多信息,请参阅字段属性

{
"mappings": {
"dynamic": true
"fields": {
"<field-name>": {
"type": "uuid",
}
}
}
}

Atlas Search uuid 类型采用以下参数:

选项
类型
必要性
说明

type

uuid

必需

标识此字段类型的人类可读标签。值必须是 uuid

后退

token