Docs Menu

Test and Run Atlas Search Queries

On this page

  • Test an Atlas Search Query
  • Run an Atlas Search Query

The Search Tester feature in the Search tab allows you to:

  • Enter the term to search in the collection.
  • Run a simple wildcard query.
  • View your Atlas Search query syntax, which you can then run in mongosh or export to a programming language.

The Search Tester returns 10 documents that are assigned a high score based on relevance.

To use the Search Tester in the Atlas UI, you must have the following:

  • An Atlas cluster running MongoDB version 4.2 or higher.
  • Atlas Search index on your collection in the Atlas cluster.
1

Click the cluster name to view cluster details and select Search tab.

2

On the index you'd like to query, click the Query button on the righthand side of the card.

3
1
2
1

Click View Query Syntax to view your query syntax in JSON format.

You can copy your query syntax in JSON format or export your query syntax to a programming language. See View, Copy, or Export Query Syntax for more information.

2

You can copy the query syntax in JSON format or export your query syntax to a programming language.

1

Click to copy the query syntax in JSON format to your clipboard. You can run the copied query in your mongosh after connecting to your Atlas cluster.

2

To export to your preferred language, click Export to Language and select the programming language and click .

3

Click Close to exit the View Query Syntax modal.

To run a Atlas Search query, you must have the following:

  • An Atlas cluster running MongoDB version 4.2 or higher.
  • Atlas Search index on your collection in the Atlas cluster.
  • A connection to the client you want to use to run the query.

The Step 2: Run Atlas Search Queries page demonstrates how to connect to your Atlas cluster and run $search queries against the sample_mflix.movies collection using the following clients. To learn more, select a client using the Select your language drop-down menu on the Step 2: Run Atlas Search Queries page.

Client
Steps

MongoDB Compass

  1. Install and see Connect via Compass to connect to your Atlas cluster using MongoDB Compass.
  2. In the MongoDB Compass Aggregations tab, manually enter your aggregation pipeline.

To learn more, see Aggregation Pipeline Builder.

Drivers
  1. Install any one of the following drivers:

  2. See Connect via Your Application to connect to your Atlas cluster using the installed driver.
  3. Define and run an aggregation pipeline in your code editor.

To learn more about running $search queries using these drivers, see Step 2: Run Atlas Search Queries. Each example in the Step 2: Run Atlas Search Queries page performs the following:

  • Creates a connection to your Atlas cluster with the MongoClient.
  • Defines a pipeline.
  • Runs the pipeline.
  • Prints the query result.
MongoDB Shell
  1. Install and see Connect via mongosh to connect to your Atlas cluster using the MongoDB Shell.
  2. Define and run an Atlas Search query.

To learn more about running $search queries using mongosh, see Step 2: Run Atlas Search Queries.

←  Count Search ResultsTune Performance →
Give Feedback
© 2022 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2022 MongoDB, Inc.