mirror of
https://github.com/HKUDS/LightRAG.git
synced 2025-11-22 04:56:59 +00:00
- Introduces an index mapping documents to their corresponding entities and relations. This significantly speeds up `adelete_by_doc_id` by replacing slow graph traversal with a fast key-value lookup. - Refactors the ingestion pipeline (`merge_nodes_and_edges`) to populate this new index. Adds a one-time data migration script to backfill the index for existing data.
26 lines
760 B
Python
26 lines
760 B
Python
from __future__ import annotations
|
|
|
|
from typing import Iterable
|
|
|
|
|
|
class NameSpace:
|
|
KV_STORE_FULL_DOCS = "full_docs"
|
|
KV_STORE_TEXT_CHUNKS = "text_chunks"
|
|
KV_STORE_LLM_RESPONSE_CACHE = "llm_response_cache"
|
|
KV_STORE_FULL_ENTITIES = "full_entities"
|
|
KV_STORE_FULL_RELATIONS = "full_relations"
|
|
|
|
VECTOR_STORE_ENTITIES = "entities"
|
|
VECTOR_STORE_RELATIONSHIPS = "relationships"
|
|
VECTOR_STORE_CHUNKS = "chunks"
|
|
|
|
GRAPH_STORE_CHUNK_ENTITY_RELATION = "chunk_entity_relation"
|
|
|
|
DOC_STATUS = "doc_status"
|
|
|
|
|
|
def is_namespace(namespace: str, base_namespace: str | Iterable[str]):
|
|
if isinstance(base_namespace, str):
|
|
return namespace.endswith(base_namespace)
|
|
return any(is_namespace(namespace, ns) for ns in base_namespace)
|