对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

连接到MongoDB Search Community

预计完成时间:5 分钟

要在 Community 中使用 MongoDB Search 和向量搜索,您必须连接到 MongoDB Community 部署。使用以下方法连接到 MongoDB Community 部署:

使用删除菜单选择本页面上的程序的接口和语言(如适用)。

在开始之前,您必须具备以下先决条件:

  • MongoDB Community and MongoDB Search Community

    注意

    确保 mongodmongot 进程都在运行。

  • 要连接的有效用户名和密码

    如果您尚未在副本集上创建用户,请在终端中运行以下命令来创建用户:

    1. 使用 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.

      重要

      请勿修改 __mdb_internal_search数据库的内容。

  • 副本集的连接字符串

    副本集的连接字符串包括所有成员节点。 因此,您需要副本集名称以及要连接的所有副本集的主机名或IP地址和端口。

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.