Docs Menu
Docs Home
/
MongoDB Atlas
/ / / /

How to Index UUID Fields for Efficient Filtering and Sorting

On this page

  • Define the Index for the uuid Type
  • Configure uuid Field Properties

Use Universally Unique Identifiers (UUIDs) when you need values that are virtually guaranteed to be unique. You can use the Atlas Search uuid type to index, query, and sort over BSON Binary Subtype 4 fields.

To define the index for the uuid type, choose your preferred configuration method in the Atlas UI and then select the database and collection.

  1. Click Refine Your Index to configure your index.

  2. In the Field Mappings section, click Add Field to open the Add Field Mapping window.

  3. Click Customized Configuration.

  4. Select the field to index from the Field Name dropdown.

  5. Click the Data Type dropdown and select Uuid.

  6. Click Add.

The following is the JSON syntax for the uuid type. Replace the default index definition with the following. To learn more about the fields, see Field Properties.

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

The Atlas Search uuid type takes the following parameters:

Option
Type
Necessity
Description

type

uuid

Required

Human-readable label that identifies this field type. Value must be uuid.

Back

token