HiRAG Indexing Process Flow
Mermaid flowchart of theprocess_indexing_job function from crates/hirag-worker/src/main.rs:107-209.
Process Overview
The HiRAG indexing process consists of four main phases:- Phase 1: Entity Extraction - Extracts entities from source text and stores them in the database
- Phase 2: Relation Extraction - Extracts relations between entities and stores them as horizontal relations
- Phase 3: Hierarchical Layer Building - Builds hierarchical layers from the knowledge graph
- Phase 4: Community Detection - Detects communities within the knowledge graph
Validation Points
- Source Text Check: If no source text is found, the process fails with an error
- Entity Count Check: If fewer than 2 entities are extracted, the process completes early (insufficient data for knowledge graph)
- Layer Building: Errors during layer building are logged and propagated
Error Handling
- Empty source text results in immediate failure
- Layer building errors are logged with full error chains before returning
- All other phases use context-aware error handling via
anyhow::Context