Skip to content

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.

Credentials

你可以在 此处 中找到此节点的身份验证信息。

¥You can find authentication information for this node here.

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:

  1. Azure 订阅

¥An Azure subscription 2. Azure AI 搜索服务

¥An Azure AI Search service 3. 已配置 API 密钥身份验证(管理员密钥用于写入操作,查询密钥用于只读操作)。

¥API key authentication configured (admin key for write operations, query key for read-only)

请参阅 凭据文档 获取设置说明。

¥See credentials documentation for setup instructions.

索引配置#

¥Index configuration

如果索引不存在,该节点会自动创建索引。自动创建时,节点会配置以下内容:

¥The node automatically creates indexes if they don't exist. When auto-creating, the node configures:

  • 基于嵌入模型的具有适当维度的向量字段

¥Vector fields with appropriate dimensions based on your embeddings model

  • HNSW 算法采用余弦度量进行高效相似性搜索。

¥HNSW algorithm for efficient similarity search with cosine metric

  • 用于筛选和检索的内容和元数据字段。

¥Content and metadata fields for filtering and retrieval

你还可以在 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
{
  "name": "n8n-vectorstore",
  "fields": [
    {
      "name": "id",
      "type": "Edm.String",
      "key": true,
      "filterable": true
    },
    {
      "name": "content",
      "type": "Edm.String",
      "searchable": true
    },
    {
      "name": "content_vector",
      "type": "Collection(Edm.Single)",
      "searchable": true,
      "vectorSearchDimensions": 1536,
      "vectorSearchProfileName": "n8n-vector-profile"
    },
    {
      "name": "metadata",
      "type": "Edm.String",
      "filterable": true
    }
  ],
  "vectorSearch": {
    "profiles": [
      {
        "name": "n8n-vector-profile",
        "algorithm": "n8n-vector-algorithm"
      }
    ],
    "algorithms": [
      {
        "name": "n8n-vector-algorithm",
        "kind": "hnsw",
        "hnswParameters": {
          "metric": "cosine",
          "m": 4,
          "efConstruction": 400,
          "efSearch": 500
        }
      }
    ]
  }
}

Vector dimensions

vectorSearchDimensions 值必须与你的嵌入模型输出匹配。

¥The vectorSearchDimensions value must match your embeddings model output.

节点使用模式#

¥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

Vector Store 检索器Question and Answer 链 一起使用,实现检索增强生成:

¥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

使用 Vector Store 问答工具 总结并回答问题:

¥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 Search semantic reranking

当你使用语义混合查询模式并配置语义参数时,Azure AI 搜索内置了 语义重排名 功能。使用方法:

¥Azure AI Search has built-in semantic reranking available when you use Semantic Hybrid query mode with a semantic configuration. To use it:

  1. 在“选项”中将“查询模式”设置为“语义混合”。

¥Set Query Mode to Semantic Hybrid in Options 2. 将“语义配置”设置为你的配置名称(如果未指定,则默认为 semantic-search-config)。

¥Set Semantic Configuration to your configuration name (defaults to semantic-search-config if not specified)

内置语义重排序器使用机器学习模型来提高相关性。你可以在语义重排序后链接一个额外的重排序节点以进行进一步的优化。

¥The built-in semantic reranker uses machine learning models to improve relevance. You can chain an additional reranking node after semantic reranking for further refinement.

仅当你的索引定义了语义配置时,语义重排名 才可用。

¥Semantic reranking is only available if your index has a semantic configuration defined.

获取多个参数#

¥Get Many parameters

  • 端点:你的 Azure AI 搜索终结点(格式:https://your-service.search.windows.net

¥Endpoint: Your Azure AI Search endpoint (format: https://your-service.search.windows.net)

  • 索引名称:要查询的索引

¥Index Name: The index to query

  • 限制:要返回的最大文档数(默认值:4)

¥Limit: Maximum documents to return (default: 4)

插入文档参数#

¥Insert Documents parameters

  • 端点:你的 Azure AI 搜索终结点

¥Endpoint: Your Azure AI Search endpoint

  • 索引名称:要使用的索引(如果不存在则自动创建)

¥Index Name: The index to use (created automatically if it doesn't exist)

  • 批处理大小:每个批次上传到 Azure AI 搜索的文档数。根据文档大小和服务层级限制进行调整。此选项仅控制上传批处理 - 嵌入生成批处理在嵌入节点中配置。

¥Batch Size: Number of documents uploaded per batch to Azure AI Search. Adjust based on document size and your service tier limits. This controls upload batching only—embedding generation batching is configured in embedding nodes.

更新文档参数#

¥Update Documents parameters

  • 端点:你的 Azure AI 搜索终结点

¥Endpoint: Your Azure AI Search endpoint

  • 索引名称:要更新的索引

¥Index Name: The index to update

检索文档参数(作为链/工具的向量存储)#

¥Retrieve Documents parameters (As Vector Store for Chain/Tool)

  • 端点:你的 Azure AI 搜索终结点

¥Endpoint: Your Azure AI Search endpoint

  • 索引名称:要查询的索引

¥Index Name: The index to query

检索文档(作为工具) (适用于 AI 代理)参数#

¥Retrieve Documents (As Tool for AI Agent) parameters

  • 名称:显示给 LLM 的工具名称

¥Name: Tool name shown to the LLM

  • 描述:向 LLM 解释此工具的功能。请具体说明,以便 LLM 选择何时使用此工具。

¥Description: Explain to the LLM what this tool does. Be specific to help the LLM choose when to use this tool.

  • 端点:你的 Azure AI 搜索终结点

¥Endpoint: Your Azure AI Search endpoint

  • 索引名称:要查询的索引

¥Index Name: The index to query

  • 限制:要检索的最大结果数(例如,10 表示十个最佳匹配项)。

¥Limit: Maximum results to retrieve (e.g., 10 for ten best matches)

节点选项#

¥Node options

选项#

¥Options

¥Filter: OData filter expression to filter results by document fields or metadata. See filter examples below.

  • 查询模式:搜索策略:

¥Query Mode: Search strategy to use:

  • 向量:仅使用嵌入进行相似性搜索

    ¥Vector: Similarity search using embeddings only

  • 关键字:使用 BM25 排名进行全文搜索。

    ¥Keyword: Full-text search using BM25 ranking

  • 混合模式(默认):结合向量搜索和关键词搜索以及互惠排序融合 (RRF)。

    ¥Hybrid (default): Combines vector and keyword search with Reciprocal Rank Fusion (RRF)

  • 语义混合:使用 语义重排名 进行混合搜索以提高相关性

    ¥Semantic Hybrid: Hybrid search with semantic reranking for improved relevance

  • 语义配置:用于 语义排名 的语义配置的名称。如果未指定,则默认为 semantic-search-config。仅当你预先创建了具有自定义语义配置名称的索引时才需要。

¥Semantic Configuration: Name of the semantic configuration to use for semantic ranking. Defaults to semantic-search-config if not specified. Only required if you pre-created an index with a custom semantic configuration name.

Query mode selection

使用“向量”进行语义相似度搜索,使用“关键词”进行精确匹配,使用“混合”进行结果平衡,或者在索引中配置语义搜索以获得最大相关性时使用“语义混合”。

¥Use Vector for semantic similarity, Keyword for exact term matching, Hybrid for balanced results, or Semantic Hybrid when you've configured semantic search in your index for maximum relevance.

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 筛选:

¥Filter by document ID:

1
id eq '3da6491a-f930-4a4e-9471-c05dcd450ba0'

按元数据字段筛选:

¥Filter by metadata field:

1
metadata/source eq 'user-guide'

复杂 AND 筛选器:

¥Complex AND filter:

1
metadata/category eq 'technology' and metadata/author eq 'John'

复杂 OR 筛选器:

¥Complex OR filter:

1
metadata/source eq 'user-guide' or metadata/rating ge 4

数值比较:

¥Numeric comparison:

1
metadata/rating ge 4 and metadata/rating lt 10

使用 NOT 进行字符串匹配:

¥String matching with NOT:

1
metadata/category eq 'technology' and metadata/title ne 'Deprecated'

支持的 OData 运算符:

¥Supported OData operators:

  • 比较:eq, ne, gt, ge, lt, le

¥Comparison: eq, ne, gt, ge, lt, le

  • 逻辑:and, or, not

¥Logical: and, or, not

  • 字符串函数:startswith(), endswith(), contains()

¥String functions: startswith(), endswith(), contains()

  • 收藏函数:any(), all()

¥Collection functions: any(), all()

Filter format

筛选器适用于所有查询模式(向量、关键字、混合、语义混合)和所有操作模式(检索、加载、工具检索)。

¥Filters work across all query modes (Vector, Keyword, Hybrid, Semantic Hybrid) and all operation modes (retrieve, load, retrieve-as-tool).

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 搜索服务中。如果使用自动创建,请检查索引是否已成功创建。

¥Index not found: Verify the index name is correct (case-sensitive) and exists in your Azure AI Search service. If using auto-creation, check that the index was created successfully.

向量维度不匹配:请确保你的嵌入模型维度与索引向量字段维度匹配。检查索引架构以确认 vectorSearchDimensions 设置。

¥Vector dimension mismatch: Ensure your embedding model dimensions match the index vector field dimensions. Check the index schema to confirm the vectorSearchDimensions setting.

文档插入失败:

¥Document insert failures:

  • 验证写入权限(需要管理员 API 密钥)。

¥Verify write permissions (admin API key required)

  • 检查文档字段是否与你的索引架构匹配。

¥Check document fields match your index schema

  • 确保文档中提供了必填字段。

¥Ensure required fields are provided in documents

  • 如果处理大型文档集时遇到超时问题,请检查批处理大小设置。

¥Review batch size settings if experiencing timeouts with large document sets

筛选问题#

¥Filter issues

筛选功能失效:

¥Filter not working:

  • 验证 OData 语法是否正确

¥Verify OData syntax is correct

  • 确保元数据字段使用 metadata/ 前缀:metadata/source eq 'value'

¥Ensure metadata fields use metadata/ prefix: metadata/source eq 'value'

  • 检查索引架构中已过滤的字段是否标记为 filterable

¥Check that filtered fields are marked as filterable in your index schema

  • 先使用简单筛选器 (id eq 'value') 进行测试,然后再测试复杂表达式。

¥Test with simple filters first (id eq 'value') before complex expressions

无效的 OData 语法:

¥Invalid OData syntax:

  • 字符串值使用单引号:metadata/source eq 'value'

¥Use single quotes for string values: metadata/source eq 'value'

  • 使用正确的运算符:eq, ne, gt, ge, lt, le, and, or, not

¥Use proper operators: eq, ne, gt, ge, lt, le, and, or, not

¥Refer to OData filter documentation for syntax details

连接问题#

¥Connection issues

无法连接:

¥Unable to connect:

  • 验证端点 URL 格式:https://your-service.search.windows.net

¥Verify endpoint URL format: https://your-service.search.windows.net

  • 确认你的 Azure AI 搜索服务正在运行且可访问

¥Confirm your Azure AI Search service is running and accessible

  • 检查网络安全组、防火墙规则和私有端点配置

¥Check network security groups, firewall rules, and private endpoint configurations

  • 对于 Azure 托管的 n8n,如果使用私有端点,请验证虚拟网络对等互连或服务端点配置。

¥For Azure-hosted n8n, verify virtual network peering or service endpoint configuration if using private endpoints

身份验证问题#

¥Authentication issues

要进行身份验证故障排除(包括 API 密钥错误),请参阅 凭据文档故障排除部分

¥For authentication troubleshooting including API key errors, refer to the credentials documentation troubleshooting section.

模板和示例#

¥Templates and examples

Template widget placeholder.

相关资源#

¥Related resources

¥Azure AI Search Vector Search documentation

¥LangChain Azure AI Search integration

¥Azure AI Search REST API reference

¥OData filter syntax for Azure AI Search

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.