document_stores.implementations.haystack_store
基于Haystack框架的文档存储实现,主要使用InMemoryDocumentStore。
该模块提供了HaystackDocumentStore类,封装了Haystack的InMemoryDocumentStore, 用于存储文档及其向量表示,并支持未来迁移到其他存储引擎。
Functions
|
创建文档存储实例的工厂函数。 |
Classes
|
基于Haystack框架的文档存储类,支持InMemoryDocumentStore和MilvusDocumentStore。 |
- class document_stores.implementations.haystack_store.HaystackDocumentStore(config=None, config_manager=None)[source]
Bases:
object基于Haystack框架的文档存储类,支持InMemoryDocumentStore和MilvusDocumentStore。
该类提供统一的接口供系统其他组件使用,并根据配置自动选择合适的存储后端。 支持文档的添加、检索、更新和删除,可通过配置文件调整参数。
支持的存储后端: - InMemoryDocumentStore: 内存存储,适用于开发和小规模场景 - MilvusDocumentStore: Milvus向量数据库,适用于生产环境和大规模场景
- __init__(config=None, config_manager=None)[source]
初始化HaystackDocumentStore对象。
- Parameters:
config_manager (ConfigManager | None) – 配置管理器对象,默认为None
- get_document(document_id)[source]
根据文档ID获取Haystack文档。
- Parameters:
document_id (str) – 系统文档ID
- Returns:
Haystack文档对象,如果不存在则返回None
- Return type:
Document | None
- get_document_store()[source]
获取底层文档存储对象。
- Returns:
InMemoryDocumentStore或MilvusDocumentStore对象
- Return type:
InMemoryDocumentStore
- get_haystack_store()[source]
获取Haystack InMemoryDocumentStore对象(用于兼容性)。
- Returns:
Haystack InMemoryDocumentStore对象
- Return type:
InMemoryDocumentStore
- get_milvus_store()[source]
获取MilvusDocumentStore对象。
- Returns:
MilvusDocumentStore对象或None
- Return type:
MilvusDocumentStore | None
- document_stores.implementations.haystack_store.create_document_store(config=None, config_manager=None)[source]
创建文档存储实例的工厂函数。
- Parameters:
config_manager (ConfigManager | None) – 配置管理器对象,默认为None
- Returns:
HaystackDocumentStore实例
- Return type: