预计完成时间:5 分钟
要在 Community 中使用 MongoDB Search 和向量搜索,您必须连接到 MongoDB Community 部署。使用以下方法连接到 MongoDB Community 部署:
MongoDB Shell 是 MongoDB 的交互式命令行界面。
MongoDB Compass,MongoDB 数据的 GUI。
一个 MongoDB 驱动程序。要查看所有可用语言,请参阅MongoDB驱动程序文档。
使用删除菜单选择本页面上的程序的接口和语言(如适用)。
先决条件
在开始之前,您必须具备以下先决条件:
MongoDB Community and MongoDB Search Community
注意
确保
mongod和mongot进程都在运行。要连接的有效用户名和密码
如果您尚未在副本集上创建用户,请在终端中运行以下命令来创建用户:
使用
mongosh连接到副本集。mongosh Run the following commands to create a
mongotUseruser in theadmindatabase with thesearchCoordinatorrole. MongoDB uses themongotUseruser to authenticatemongotwithmongod.use admin db.createUser( { user: "mongotUser", pwd: passwordPrompt(), roles: [ { role: "searchCoordinator", db: "admin" } ] } ) Users with the
searchCoordinatorrole havereadAnyDatabaseprivileges and write permissions on the__mdb_internal_searchdatabase.重要
请勿修改
__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.