Azure AI 搜索向量存储节点(Azure AI Search Vector Store node)#
Azure AI 搜索(原名 Azure 认知搜索)是一项云搜索服务,具有用于 RAG 和语义搜索应用的向量搜索功能。使用此节点可以存储、检索并查询向量嵌入及其内容和元数据。
🌐 Azure AI Search (formerly Azure Cognitive Search) is a cloud search service with vector search capabilities for RAG and semantic search applications. Use this node to store, retrieve, and query vector embeddings alongside their content and metadata.
本页提供 Azure AI 搜索向量存储节点的参数以及更多资源的链接。
🌐 On this page, you'll find the node parameters for the Azure AI Search Vector Store node, and links to more resources.
凭证
你可以在这里找到该节点的认证信息。
Parameter resolution in sub-nodes
Sub-nodes behave differently to other nodes when processing multiple items using an expression.
Most nodes, including root nodes, take any number of items as input, process these items, and output the results. You can use expressions to refer to input items, and the node resolves the expression for each item in turn. For example, given an input of five name values, the expression {{ $json.name }} resolves to each name in turn.
In sub-nodes, the expression always resolves to the first item. For example, given an input of five name values, the expression {{ $json.name }} always resolves to the first name.
先决条件(Prerequisites)#
使用此节点前,你需要:
🌐 Before using this node, you need:
- 一个 Azure 订阅
- 一个 Azure AI 搜索服务
- 已配置 API 密钥身份验证(管理员密钥用于写入操作,查询密钥用于只读操作)。
请参阅凭证文档以获取设置说明。
索引配置(Index configuration)#
如果索引不存在,节点会自动创建索引。在自动创建时,节点会配置:
🌐 The node automatically creates indexes if they don't exist. When auto-creating, the node configures:
- 基于嵌入模型的具有适当维度的向量字段
- HNSW 算法采用余弦度量进行高效相似性搜索。
- 用于筛选和检索的内容和元数据字段。
你还可以在 Azure 门户中为自定义配置预先创建索引。示例模式:
🌐 You can also pre-create indexes in Azure Portal for custom configurations. Example schema:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
向量维度
vectorSearchDimensions 值必须与你的嵌入模型输出匹配。
节点使用模式(Node usage patterns)#
作为常规应用使用用于插入和检索文档的节点(Use as a regular node to insert and retrieve documents)#
在工作流中直接使用该节点来插入或检索文档,无需代理。请参阅此模板了解示例模式(使用 Supabase,但模式是相同的)。
🌐 Use the node directly in workflows to insert or retrieve documents without an agent. See this template for an example pattern (uses Supabase, but the pattern is identical).
直接连接到 AI 代理作为工具(Connect directly to an AI agent as a tool)#
连接到 AI 代理 的工具连接器,以将向量存储用作可搜索的知识库:
🌐 Connect to an AI agent's tool connector to use the vector store as a searchable knowledge base:
AI 代理(工具连接器)→ Azure AI Search Vector Store 节点
🌐 AI agent (tools connector) → Azure AI Search Vector Store node
使用检索器获取文档(Use a retriever to fetch documents)#
与 向量存储检索器 和 问答链 一起使用,以实现检索增强生成:
🌐 Use with Vector Store Retriever and Question and Answer Chain for retrieval-augmented generation:
问答链(检索器)→ 向量存储检索器(向量存储)→ Azure AI 搜索向量存储。
🌐 Question and Answer Chain (Retriever) → Vector Store Retriever (Vector Store) → Azure AI Search Vector Store
请参见此示例工作流程。
🌐 See this example workflow.
使用 Vector Store 问答工具(Use the Vector Store Question Answer Tool)#
使用 向量存储问答工具 来总结和回答问题:
🌐 Use Vector Store Question Answer Tool to summarize and answer questions:
AI 代理(工具)→ Vector Store 问答工具(Vector Store)→ Azure AI Search Vector Store
🌐 AI agent (tools) → Vector Store Question Answer Tool (Vector Store) → Azure AI Search Vector Store
请参见此示例。
🌐 See this example.
节点参数(Node parameters)#
This Vector Store node has five modes: Get Many, Insert Documents, Retrieve Documents (As Vector Store for Chain/Tool), Retrieve Documents (As Tool for AI Agent), and Update Documents. The mode you select determines the operations you can perform with the node and what inputs and outputs are available.
Get Many#
In this mode, you can retrieve multiple documents from your vector database by providing a prompt. The prompt will be embedded and used for similarity search. The node will return the documents that are most similar to the prompt with their similarity score. This is useful if you want to retrieve a list of similar documents and pass them to an agent as additional context.
Insert Documents#
Use Insert Documents mode to insert new documents into your vector database.
Retrieve Documents (As Vector Store for Chain/Tool)#
Use Retrieve Documents (As Vector Store for Chain/Tool) mode with a vector-store retriever to retrieve documents from a vector database and provide them to the retriever connected to a chain. In this mode you must connect the node to a retriever node or root node.
Retrieve Documents (As Tool for AI Agent)#
Use Retrieve Documents (As Tool for AI Agent) mode to use the vector store as a tool resource when answering queries. When formulating responses, the agent uses the vector store when the vector store name and description match the question details.
Update Documents#
Use Update Documents mode to update documents in a vector database by ID. Fill in the ID with the ID of the embedding entry to update.
重新排序结果(Rerank Results)#
Enables reranking. If you enable this option, you must connect a reranking node to the vector store. That node will then rerank the results for queries. You can use this option with the Get Many, Retrieve Documents (As Vector Store for Chain/Tool) and Retrieve Documents (As Tool for AI Agent) modes.
Azure AI 搜索语义重排序
当你在语义配置下使用 Semantic Hybrid 查询模式时,Azure AI Search 提供内置的语义重新排序。使用方法如下:
- 在“选项”中将 查询模式 设置为 Semantic Hybrid
- 将 语义配置 设置为你的配置名称(如果未指定,默认为
semantic-search-config)
内置的语义重新排序器使用机器学习模型来提高相关性。你可以在语义重新排序之后链接一个额外的重新排序节点以进一步优化。
语义重新排序 仅在你的索引定义了语义配置时可用。
获取多个参数(Get Many parameters)#
- 端点:你的 Azure AI 搜索端点(格式:
https://your-service.search.windows.net) - 索引名称:要查询的索引
- 限制:返回的最大文档数(默认值:4)
插入文档参数(Insert Documents parameters)#
- 端点:你的 Azure AI 搜索端点
- 索引名称:要使用的索引(如果不存在将自动创建)
- 批处理大小:每批上传到 Azure AI 搜索的文档数量。根据文档大小和你的服务级别限制进行调整。这仅控制上传批处理——嵌入生成的批处理是在嵌入节点中配置的。
更新文档参数(Update Documents parameters)#
- 端点:你的 Azure AI 搜索端点
- 索引名称:要更新的索引
检索文档参数(作为链/工具的向量存储)(Retrieve Documents parameters (As Vector Store for Chain/Tool))#
- 端点:你的 Azure AI 搜索端点
- 索引名称:要查询的索引
检索文档(作为工具) (适用于 AI 代理)参数(Retrieve Documents (As Tool for AI Agent) parameters)#
- 名称:显示给大型语言模型的工具名称
- 描述:向大语言模型(LLM)解释此工具的功能。请具体说明,以帮助大语言模型判断何时使用此工具。
- 端点:你的 Azure AI 搜索端点
- 索引名称:要查询的索引
- 限制:要检索的最大结果数(例如,
10表示前十个最佳匹配)
节点选项(Node options)#
选项(Options)#
- 筛选:使用 OData 筛选表达式 根据文档字段或元数据筛选结果。请参见以下筛选示例。
- 查询模式:要使用的搜索策略:
- 向量:仅使用嵌入进行相似性搜索
- 关键词:使用 BM25 排名的全文搜索
- 混合(默认):结合向量搜索和关键词搜索,并使用互惠排名融合(RRF)
- 语义混合:采用语义重排序的混合搜索以提高相关性
- 语义配置:用于语义排序的语义配置名称。如果未指定,则默认为
semantic-search-config。仅在你预先创建了带有自定义语义配置名称的索引时才需要。
查询模式选择
使用 Vector 进行语义相似度匹配,使用 Keyword 进行精确术语匹配,使用 Hybrid 获取平衡的结果,或在索引中配置了语义搜索以获得最大相关性时使用 Semantic Hybrid。
OData 过滤器示例(OData filter examples)#
Azure AI 搜索使用 OData 语法 进行筛选。元数据字段使用 metadata/fieldName 格式访问。
🌐 Azure AI Search uses OData syntax for filtering. Metadata fields are accessed using metadata/fieldName format.
按文档ID过滤:
1 | |
按元数据字段过滤:
1 | |
复杂 AND 筛选器:
1 | |
复杂 OR 筛选器:
1 | |
数字比较:
1 | |
使用 NOT 进行字符串匹配:
1 | |
支持的 OData 运算符:
- 比较:
eq、ne、gt、ge、lt、le - 逻辑:
and、or、not - 字符串函数:
startswith()、endswith()、contains() - 集合函数:
any()、all()
过滤器格式
筛选器适用于所有查询模式(向量、关键字、混合、语义混合)以及所有操作模式(检索、加载、作为工具检索)。
Azure AI 搜索特定功能(Azure AI Search specific features)#
使用 RRF 的混合搜索(Hybrid search with RRF)#
Azure AI 搜索的混合搜索使用互惠排名融合来合并向量和关键字结果,从而提供比单独使用任何一种方法都更高的准确性。
🌐 Azure AI Search's hybrid search uses Reciprocal Rank Fusion to merge vector and keyword results, providing better accuracy than either method alone.
语义排名(Semantic ranking)#
语义混合模式应用机器学习模型,根据对你查询的语义理解重新排序结果。这需要在你的索引中进行语义配置。
🌐 Semantic Hybrid mode applies machine learning models to rerank results based on semantic understanding of your query. This requires a semantic configuration in your index.
OData 过滤器(OData filters)#
在执行向量搜索之前,使用 OData 语法按文档字段或元数据进行筛选。当你需要来自特定来源或具有特定属性的结果时,这可以提高性能和精准度。
🌐 Use OData syntax to filter by document fields or metadata before vector search executes. This improves performance and precision when you need results from specific sources or with certain attributes.
HNSW 算法(HNSW algorithm)#
Azure AI 搜索使用分层可导航小世界 (HNSW) 图进行近似最近邻搜索,可在大规模下提供快速检索,并可配置准确性/速度之间的权衡。
🌐 Azure AI Search uses Hierarchical Navigable Small World (HNSW) graphs for approximate nearest neighbor search, providing fast retrieval at scale with configurable accuracy/speed tradeoffs.
故障排除(Troubleshooting)#
索引问题(Index issues)#
未找到索引:请确认索引名称正确(区分大小写)且在你的 Azure AI 搜索服务中存在。如果使用自动创建,请检查索引是否创建成功。
向量维度不匹配:请确保你的嵌入模型维度与索引向量字段维度一致。检查索引架构以确认 vectorSearchDimensions 设置。
文档插入失败:
- 验证写入权限(需要管理员 API 密钥)。
- 检查文档字段是否与你的索引架构匹配。
- 确保文档中提供了必填字段。
- 如果处理大型文档集时遇到超时问题,请检查批处理大小设置。
筛选问题(Filter issues)#
过滤器不起作用:
- 验证 OData 语法是否正确
- 确保元数据字段使用
metadata/前缀:metadata/source eq 'value' - 检查过滤字段在索引模式中是否标记为
filterable - 先用简单的过滤器测试(
id eq 'value'),再使用复杂表达式
无效的 OData 语法:
- 字符串值使用单引号:
metadata/source eq 'value' - 使用正确的运算符:
eq、ne、gt、ge、lt、le、and、or、not - 有关语法详情,请参阅 OData 过滤器文档
连接问题(Connection issues)#
无法连接:
- 验证端点 URL 格式:
https://your-service.search.windows.net - 确认你的 Azure AI 搜索服务正在运行且可访问
- 检查网络安全组、防火墙规则和私有端点配置
- 对于 Azure 托管的 n8n,如果使用私有端点,请验证虚拟网络对等互连或服务端点配置。
身份验证问题(Authentication issues)#
有关身份验证故障排除,包括 API 密钥错误,请参阅凭据文档故障排除部分。
🌐 For authentication troubleshooting including API key errors, refer to the credentials documentation troubleshooting section.
模板和示例(Templates and examples)#
相关资源(Related resources)#
View n8n's Advanced AI documentation.
Self-hosted AI Starter Kit#
New to working with AI and using self-hosted n8n? Try n8n's self-hosted AI Starter Kit to get started with a proof-of-concept or demo playground using Ollama, Qdrant, and PostgreSQL.