Docs Menu
Docs Home
MongoDB Atlas
/ / / /

How to Index Date Fields For Faceted Search

On this page

  • Review dateFacet Limitations
  • Define the Index for dateFacet Type
  • Configure dateFacet Field Properties
  • Try an Example for dateFacet Type

You can use the Atlas Search dateFacet type for indexing date values for faceting.

Atlas Search only supports facet queries against fields indexed as the dateFacet type. To perform a normal search also on the same field, you must index the field as type date also.

To facet on string fields in embedded documents, you must index the parent fields as the document type. When you facet on a string field inside embedded documents, Atlas Search returns facet count for only the number of matching parent documents.

Atlas Search doesn't dynamically index date values for faceting. You must use static mappings to index date values for faceting. You can use the Visual Editor or the JSON Editor in the Atlas UI to index date fields as the dateFacet type.

The following limitations apply:

  • You can't index a date field for faceting if it's inside an array or if it's inside a document in an array.

  • Atlas Search doesn't support date faceting over fields indexed as part of an embeddedDocuments field.


    To vote for this feature and provide your feedback, use this MongoDB feedback article.

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

The Atlas Search dateFacet type takes the following parameter:

UI Field Name
JSON Option
Data Type
Human-readable label that identifies this field type. Value must be dateFacet.

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.


See also: Additional Index Definition Examples

← How to Index Date Fields