mongodb/mongodb-atlas-searchAtlas Search 是 MongoDB Atlas 提供的嵌入式全文搜索功能,旨在为应用提供无缝、可扩展的基于相关性的搜索能力。本镜像主要用于本地测试与开发环境,帮助开发人员复现 Atlas Search 及 Atlas Vector Search 的核心功能,验证搜索逻辑、相关性排序及向量检索等特性,为生产环境部署前的功能调试与原型验证提供支持。
$search 聚合阶段)在不同场景下的表现。bash# 安装 Atlas CLI(以 macOS 为例,其他系统参考官方文档) brew tap mongodb/brew && brew install mongodb-atlas-cli # 初始化 CLI 并登录 Atlas 账户 atlas login
通过 atlas deploy local 命令启动包含 Atlas Search 的本地 MongoDB 实例:
bash# 部署本地单节点实例,默认启用 Atlas Search 和 Vector Search atlas deploy local --search --vector-search # 自定义配置(如端口、资源限制) atlas deploy local --search --vector-search \ --port 27018 \ # 自定义 MongoDB 端口(默认 27017) --memory 4g \ # 分配内存资源(默认 2g) --volume ./data # 挂载本地数据目录(持久化存储)
bash# 查看本地部署状态 atlas deploy local status # 输出示例: # Local deployment is running (ID: local-abc123) # MongoDB URI: mongodb://localhost:27017/?directConnection=true # Atlas Search enabled: true # Vector Search enabled: true
使用 MongoDB Shell(mongosh)连接本地实例,执行搜索查询验证功能:
bash# 连接本地实例 mongosh "mongodb://localhost:27017" # 创建测试集合并插入数据 use testdb db.books.insertMany([ { title: "MongoDB in Action", content: "A guide to MongoDB development" }, { title: "Atlas Search Essentials", content: "Full-text search with MongoDB Atlas" } ]) # 创建 Atlas Search 索引(需通过 Atlas CLI 或本地配置文件定义) # 索引定义示例(保存为 search_index.json): # { # "mappings": { # "dynamic": true, # "fields": { # "content": { "type": "string" }, # "title": { "type": "string" } # } # } # } # 通过 CLI 创建索引 atlas deploy local search index create --db testdb --coll books --file search_index.json --indexName book_index # 执行全文搜索查询 db.books.aggregate([ { $search: { index: "book_index", text: { query: "MongoDB", path: ["title", "content"] } } }, { $project: { title: 1, score: { $meta: "searchScore" } } } ])
| 参数名 | 类型 | 描述 | 默认值 |
|---|---|---|---|
--search | 标志 | 启用 Atlas Search 功能 | false |
--vector-search | 标志 | 启用 Atlas Vector Search 功能 | false |
--port | 整数 | MongoDB 服务端口 | 27017 |
--memory | 字符串 | 分配的内存资源(如 2g、4g) | 2g |
--volume | 字符串 | 本地数据目录挂载路径 | 临时目录(非持久化) |
--username | 字符串 | MongoDB 认证用户名 | 无(默认禁用认证) |
--password | 字符串 | MongoDB 认证密码 | 无 |
| 环境变量名 | 描述 | 示例值 |
|---|---|---|
ATLAS_LOCAL_DEPLOY_ID | 本地部署实例唯一标识(自动生成) | local-abc123 |
MONGODB_URI | 本地实例连接 URI(部署后自动生成) | mongodb://localhost:27017 |
atlas deploy local --version 指定与生产集群匹配的版本。atlas deploy local stop --clean 命令可停止并清除本地实例数据,避免磁盘占用。manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务