spring-ai-weaviate-store-spring-boot-starter
依赖项添加到项目的 pom.xml
文件中。
该启动器包含了 spring-ai-core
和 Weaviate Java 客户端库。
EmbeddingClient
实现来为您的文档生成向量嵌入。例如,您可以添加 spring-ai-openai-spring-boot-starter
以使用 OpenAI 的嵌入模型:
application.properties
或 application.yml
文件中配置 Weaviate 和嵌入客户端属性。
属性 | 描述 | 默认值 |
---|---|---|
spring.ai.vectorstore.weaviate.scheme | Weaviate 服务器的 scheme (例如 http 或 https ) | http |
spring.ai.vectorstore.weaviate.host | Weaviate 服务器的主机名或 IP 地址 | localhost |
spring.ai.vectorstore.weaviate.api-key | 用于向 Weaviate 服务器进行身份验证的 API 密钥 (如果需要) | |
spring.ai.vectorstore.weaviate.object-class | 用于存储文档的 Weaviate 类名 | SpringAiDocument |
spring.ai.vectorstore.weaviate.consistency-level | 写入操作的一致性级别 (例如 ONE , QUORUM , ALL ) | ONE |
spring.ai.vectorstore.weaviate.headers.* | 要包含在发送到 Weaviate 的请求中的自定义标头 | |
spring.ai.vectorstore.weaviate.filter-fields.text-fields | 指定哪些元数据文本字段应该被索引以进行 Weaviate 的 like 过滤。逗号分隔的列表。 | (空) |
spring.ai.vectorstore.weaviate.filter-fields.tokenizable-fields | 指定哪些元数据字段应该被索引为 Weaviate 的 tokenizable 字段。逗号分隔的列表。 | (空) |
application.properties
:
EmbeddingClient
配置为生成具有一致维度的嵌入。VectorStore
VectorStore
bean 注入到您的组件中以与之交互:
WeaviateVectorStore
Bean (可选)WeaviateVectorStore
bean。但是,如果您需要自定义配置,可以定义自己的 bean:
where
过滤器格式。
示例:
like
(通配符) 过滤,您需要在 spring.ai.vectorstore.weaviate.filter-fields.text-fields
属性中指定这些字段,以便在 schema 中正确设置它们。
同样,对于需要标记化的字段,请使用 spring.ai.vectorstore.weaviate.filter-fields.tokenizable-fields
。WeaviateVectorStore
支持通过文档 ID 删除数据。