Search Fundamentals / Creating an Atlas Search Index: Data Types

Code Recap: Creating an Atlas Search Index: Data Types

Define an Atlas Search Index

The following example creates a static search index named titlePlotReleasedIndex, which uses the string field type on the title and plot fields and the date field type on the released field:

 db.movies.createSearchIndex(
  "titlePlotReleasedIndex",
  {
    mappings: {
      dynamic: false,
      fields: {
        title: {
          type: "string"
        },
        plot: {
          type: "string"
        },
        released: {
          type: "date"
        }
      }
    }
  }
);