Docs Menu

Docs HomeLaunch & Manage MongoDBMongoDB Atlas

How to Sort Your Atlas Search Results

On this page

  • Load the Sample Data
  • Overview
  • Procedure
  • Create the Atlas Search Index
  • Overview
  • Procedure
  • Sort Your Search Results
  • Sort Numbers
  • Sort Dates
  • Sort Strings

This tutorial describes how to sort the Atlas Search results by numeric, date, and string fields in the sample_mflix.movies collection in ascending or descending order. It also demonstrates how to perform a case-insensitive sort of your Atlas Search results. When you create an Atlas Search index on a collection, you can configure the index to normalize the value of a string field to lowercase. This allows you to sort your query results regardless of the sorted field's letter case.

Before you begin, ensure that your Atlas cluster meets the requirements described in the Prerequisites.

To create an Atlas Search index, you must have Project Data Access Admin or higher access to the project.


Use the Select your language drop-down menu to set the language of the example in this section.


You can sort your search results in multiple ways. In this section, you connect to your Atlas cluster and then run the sample queries against the indexed fields in the sample_mflix.movies collection.

← How to Run Atlas Search String Queries Against Date and Numeric Fields