Redis 向量存储节点(Redis Vector Store node)#
使用 Redis 向量存储节点来与你的 Redis 数据库作为 向量存储 进行交互。你可以将文档插入向量数据库,从向量数据库获取文档,使用连接到 链 的检索器检索文档,或者直接将其连接到 代理 以用作 工具。
🌐 Use the Redis Vector Store node to interact with your Redis database as a vector store. You can insert documents into the vector database, get documents from the vector database, retrieve documents using a retriever connected to a chain, or connect it directly to an agent to use as a tool.
本页提供 Redis 向量存储节点的参数以及更多资源的链接。
🌐 On this page, you'll find the node parameters for the Redis 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)#
在使用此节点之前,你需要一个启用了 Redis 查询引擎 的 Redis 数据库。请使用以下选项之一:
🌐 Before using this node, you need a Redis database with the Redis Query Engine enabled. Use one of the following:
- Redis 开源版(v8.0 及以上):默认包含 Redis 查询引擎
- Redis Cloud:全托管服务
- Redis 软件:自我管理部署
如果你没有索引,将会创建一个新的索引。
提前创建自己的索引只有在你想使用自定义索引架构或重用现有索引时才是必要的。否则,你可以跳过此步骤,让节点根据你指定的选项为你创建一个新的索引。
节点使用模式(Node usage patterns)#
你可以在以下模式下使用 Redis 向量存储节点:
🌐 You can use the Redis Vector Store node in the following patterns:
作为常规应用使用用于插入和检索文档的节点(Use as a regular node to insert and retrieve documents)#
您可以将 Redis 向量存储用作常规节点来插入或获取文档。这种模式将 Redis 向量存储放在常规连接流程中,而无需使用代理。
🌐 You can use the Redis Vector Store as a regular node to insert or get documents. This pattern places the Redis Vector Store in the regular connection flow without using an agent.
你可以在这个模板中看到一个例子,其中语义缓存存储在 Redis 中,并在工作流开始时使用 Redis 向量存储节点进行检索。
🌐 You can see an example in this template where the semantic cache is stored in Redis and retrieved using the Redis Vector Store node in the start of the workflow.
直接连接到 AI 代理作为工具(Connect directly to an AI agent as a tool)#
你可以将 Redis 向量存储节点直接连接到 AI 代理 的 工具 连接器,以在回答查询时将向量存储用作资源。
🌐 You can connect the Redis Vector Store node directly to the tool connector of an AI agent to use a vector store as a resource when answering queries.
这里,连接将是:AI 代理(工具连接器)-> Redis 向量存储节点。
🌐 Here, the connection would be: AI agent (tools connector) -> Redis Vector Store node.
使用检索器获取文档(Use a retriever to fetch documents)#
您可以将 Vector Store Retriever 节点与 Redis Vector Store 节点一起使用,从 Redis Vector Store 节点获取文档。这通常与 Question and Answer Chain 节点一起使用,以从向量存储中获取与给定聊天输入匹配的文档。
🌐 You can use the Vector Store Retriever node with the Redis Vector Store node to fetch documents from the Redis Vector Store node. This is often used with the Question and Answer Chain node to fetch documents from the vector store that match the given chat input.
一个连接流程示例(链接的示例使用了 Pinecone,但模式相同)如下:问答链(检索器连接器)-> 向量存储检索器(向量存储连接器)-> Redis 向量存储。
🌐 An example of the connection flow (the linked example uses Pinecone, but the pattern is the same) would be: Question and Answer Chain (Retriever connector) -> Vector Store Retriever (Vector Store connector) -> Redis Vector Store.
使用 Vector Store 问答工具回答问题(Use the Vector Store Question Answer Tool to answer questions)#
另一种模式使用 Vector Store Question Answer Tool 来总结结果并回答来自 Redis 向量存储节点的问题。与直接将 Redis 向量存储连接为工具不同,这种模式使用专门设计的工具来汇总向量存储中的数据。
🌐 Another pattern uses the Vector Store Question Answer Tool to summarize results and answer questions from the Redis Vector Store node. Rather than connecting the Redis Vector Store directly as a tool, this pattern uses a tool specifically designed to summarizes data in the vector store.
此模板展示了如何使用带有 Redis 向量存储节点的向量存储问答工具。在这种情况下,连接流程如下:AI 代理(工具连接器)-> 向量存储问答工具(向量存储连接器)-> Redis 向量存储。
🌐 This template shows how to use the Vector Store Question Answer Tool with the Redis Vector Store node. The connections flow in this case would look like this: AI agent (tools connector) -> Vector Store Question Answer Tool (Vector Store connector) -> Redis Vector store.
节点参数(Node parameters)#
Operation Mode#
This Vector Store node has four modes: Get Many, Insert Documents, Retrieve Documents (As Vector Store for Chain/Tool), and Retrieve Documents (As Tool for AI Agent). 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 is embedded and used for similarity search. The node returns 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.
重新排序结果(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.
获取多个参数(Get Many parameters)#
- Redis 索引:输入要使用的 Redis 向量搜索索引名称。也可以从列表中选择已有索引。
- 提示:请输入搜索查询。
- 限制:输入要从向量存储中获取的结果数量。例如,将其设置为
10可获取十个最佳结果。
此操作模式包括一个 节点选项,元数据过滤器。
🌐 This Operation Mode includes one Node option, the Metadata Filter.
插入文档参数(Insert Documents parameters)#
- Redis 索引:输入要使用的 Redis 向量搜索索引名称。也可以从列表中选择已有索引。
检索文档(作为链/工具的向量存储)参数(Retrieve Documents (As Vector Store for Chain/Tool) parameters)#
- Redis 索引:输入要使用的 Redis 向量搜索索引名称。也可以从列表中选择已有索引。
此操作模式包括一个 节点选项,元数据过滤器。
🌐 This Operation Mode includes one Node option, the Metadata Filter.
检索文档(作为工具) (适用于 AI 代理)参数(Retrieve Documents (As Tool for AI Agent) parameters)#
- 名称:向量存储的名称。
- 描述:向大型语言模型(LLM)解释此工具的功能。具体而清晰的描述可以让大型语言模型更频繁地产生预期的结果。
- Redis 索引:输入要使用的 Redis 向量搜索索引名称。也可以从列表中选择已有索引。
- 限制:输入要从向量存储中获取的结果数量。例如,将其设置为
10可获取十个最佳结果。
包含元数据(Include Metadata)#
是否包含文档元数据。
🌐 Whether to include document metadata.
你可以将此与 Get Many 和 Retrieve Documents (As Tool for AI Agent) 模式一起使用。
🌐 You can use this with the Get Many and Retrieve Documents (As Tool for AI Agent) modes.
节点选项(Node options)#
元数据筛选器(Metadata Filter)#
元数据过滤器可用于 Get Many、Retrieve Documents (作为链/工具的向量存储) 和 Retrieve Documents (作为 AI 代理的工具) 操作模式。 这是一个 OR 查询。如果你指定多个元数据过滤字段,则至少需要匹配其中一个。 插入数据时,元数据是通过文档加载器设置的。有关加载文档的更多信息,请参阅 默认数据加载器。
🌐 Metadata filters are available for the Get Many, Retrieve Documents (As Vector Store for Chain/Tool), and Retrieve Documents (As Tool for AI Agent) operation modes.
This is an OR query. If you specify more than one metadata filter field, at least one of them must match.
When inserting data, the metadata is set using the document loader. Refer to Default Data Loader for more information on loading documents.
Redis 配置选项(Redis Configuration Options)#
适用于所有操作模式:
🌐 Available for all operation modes:
- 元数据键:输入 Redis 哈希中元数据字段的键(默认值:
metadata)。 - 密钥前缀:输入用于存储文档的密钥前缀(默认:
doc:)。 - 内容键:输入 Redis 哈希中内容字段的键(默认值:
content)。 - 嵌入键:输入 Redis 哈希中嵌入字段的键(默认值:
embedding)。
插入选项(Insert Options)#
适用于 插入文档 操作模式:
🌐 Available for the Insert Documents operation mode:
- 覆盖文档:选择是否覆盖现有文档(开启表示覆盖,关闭表示不覆盖)。同时会删除索引。
- 存活时间:输入文档的存活时间(以秒为单位)。不会使索引过期。
模板和示例(Templates and examples)#
相关资源(Related resources)#
参考:
🌐 Refer to:
- 有关 Redis 向量功能的更多信息,请参阅 Redis 向量搜索文档。
- 有关 RediSearch 的更多信息,请参阅 RediSearch 文档。
- 有关该服务的更多信息,请参阅 LangChain 的 Redis 向量存储文档。
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.