Skip to main content

HiRAG Indexing Process Flow

Mermaid flowchart of the process_indexing_job function from crates/hirag-worker/src/main.rs:107-209.

Process Overview

The HiRAG indexing process consists of four main phases:
  1. Phase 1: Entity Extraction - Extracts entities from source text and stores them in the database
  2. Phase 2: Relation Extraction - Extracts relations between entities and stores them as horizontal relations
  3. Phase 3: Hierarchical Layer Building - Builds hierarchical layers from the knowledge graph
  4. 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