For AI agents: a documentation index is available at https://www.mongodb.com/docs/llms.txt — markdown versions of all pages are available by appending .md to any URL path.
Docs Menu

Connect to MongoDB Search Community

Estimated completion time: 5 minutes

To use MongoDB Search and Vector Search in Community, you must connect to your MongoDB Community deployment. Use the following methods to connect to your MongoDB Community deployment:

Use the drop-down menus to select the interface and languages, when applicable, for the procedure on this page.

Before you start, you must have the following prerequisites:

  • MongoDB Community and MongoDB Search Community

    Note

    Make sure that both the mongod and mongot processes are running.

  • Valid username and password to connect

    If you haven't already created a user on your replica set, run the following commands in your terminal to create a user:

    1. Connect to replica set by using mongosh.

      mongosh
    2. Run the following commands to create a mongotUser user in the admin database with the searchCoordinator role. MongoDB uses the mongotUser user to authenticate mongot with mongod.

      use admin
      db.createUser( {
      user: "mongotUser",
      pwd: passwordPrompt(),
      roles: [ { role: "searchCoordinator", db: "admin" } ]
      } )

      Users with the searchCoordinator role have readAnyDatabase privileges and write permissions on the __mdb_internal_search database.

      Important

      Do not modify the contents of the __mdb_internal_search database.

  • Connection string to the replica set

    The connection string for a replica set includes all member nodes. Therefore, you need the replica set name and the hostnames or IP addresses and ports of all the replica set members to connect.

Use your replica set's connection string to connect to your replica set with your preferred client. To ensure that you configured mongot and mongod correctly, you can run a command that retrieves search indexes.

Now that you've connected to your replica set, proceed to Query with MongoDB Search and Vector Search in Community.