本文档提供有关解决MongoDB Vector Search 问题的建议。要获得有关MongoDB Vector Search 问题的直接帮助,您可以在 Reddit 或Stack Overflow上的MongoDB社区上发起讨论,或者联系支持。
无法在集群上使用 $vectorSearch 阶段
要使用 $vectorSearch管道阶段查询集群,集群必须运行MongoDB 7.0.2+。如果您在不兼容的MongoDB版本上调用 $vectorSearch,则可能会看到以下错误:
OperationFailure: $vectorSearch is not allowed with the current configuration. You may need to enable the corresponding feature flag.
要检查集群的 MongoDB 版本,请执行以下操作:
AtlasGoClusters在Atlas中,Go项目的 页面。
如果尚未显示,请从导航栏上的 Organizations 菜单中选择包含所需项目的组织。
如果尚未显示,请从导航栏的Projects菜单中选择所需的项目。
在侧边栏中,单击 Database 标题下的 Clusters。
会显示集群页面。
找到要使用$vectorSearch的集群的信息窗格。
请查阅信息窗格底部的Version号码。
If your cluster runs a version of MongoDB earlier than 6.0.11 or 7.0.2, you must upgrade the MongoDB version of the cluster.
慢查询
有关提高查询性能的建议,请参阅MongoDB Vector Search 基准。
$vectorSearch 未返回任何结果
如果 $vectorSearch 查询未返回结果,请执行以下操作:
确保您对数据和查询使用相同的嵌入模型。 如果嵌入查询使用的模型与嵌入数据时使用的模型不同,则
$vectorSearch无法识别匹配项。Ensure that your MongoDB Vector Search has finished building. When you create or update a MongoDB Vector Search index, the index the index is in an initial sync state. When it finishes building, you can start querying the data in your collection.
Error during document retrieval 使用 LangChain 进行筛选时
使用 LangChain 执行带有预过滤功能的 RAG 时,您可能会遇到以下错误:
Error during the document retrieval or generation process: MongoServerError: PlanExecutor error during aggregation :: caused by :: Path 'field' needs to be indexed as token
If an index on field exists, ensure you have created this index as a MongoDB Vector Search index, not a MongoDB Search index. If no index on field exists, create one. To learn more about implementing RAG with MongoDB Vector Search and LangChain, see Answer Questions on Your Data.
Command not found 创建MongoDB Vector Search索引时
当您尝试以编程方式创建MongoDB Vector Search索引时,可能会遇到 Command not found 错误。出现此错误的原因有两个:
You run the command against a cluster running a version of MongoDB earlier than 6.0.11 or 7.0.2. In this case, you must upgrade the MongoDB version of the cluster to enable MongoDB Vector Search for the cluster.
您可以针对免费集群(以前称为
M0)运行该命令。在这种情况下,只要集群运行的是兼容的MongoDB版本,您就可以使用Atlas用户界面创建MongoDB Vector Search索引。
无法筛选给定字段
MongoDB Vector Search 目前仅支持对具有布尔值、日期、数字、ObjectId、字符串和 UUID 值的字段进行筛选。 要学习;了解更多信息,请参阅关于 filter 类型。