On this page
You can use the Atlas Search
date type to index date values. You can query
fields of type
date using the Atlas Search range, near,
and equals operators. To run a facet query on
date fields, you must index the date fields using
You can also use the
date type to index:
Fields whose value is an array of dates. To learn more, see How to Index the Elements of an Array.
Date fields inside an array of documents indexed as the embeddedDocuments type.
Date fields for sorting. Atlas Search automatically indexes all date fields in indexes created after July 2023 for sorting the Atlas Search results. For preexisting indexes, you must rebuild the index to use date fields in the index for sorting. To learn more, see Rebuild Index for Sorting and Sort Atlas Search Results.
If you enable dynamic mappings, Atlas Search
automatically indexes fields of type
date. You can
use the Visual Editor or the JSON Editor in the Atlas UI to
index fields as the
To define the index for the
date type, choose your preferred
configuration method in the Atlas UI and then select the
database and collection.
The Atlas Search
date type takes the following parameter:
Human-readable label that identifies this field type. Value must be
The following index definition example uses the sample_mflix.movies collection. If you have the sample data already loaded on your cluster, you can use the Visual Editor or JSON Editor in the Atlas UI to configure the index. After you select your preferred configuration method, select the database and collection, and refine your index to add field mappings.