Skip to main content
The index API enables you to build and update knowledge graph indexes from your documents using Python.

build_index

Build a knowledge graph index from documents.

Parameters

config
GraphRagConfig
required
The GraphRAG configuration object. Load from a YAML file using GraphRagConfig.from_file("settings.yaml") or construct programmatically.
method
IndexingMethod | str
default:"IndexingMethod.Standard"
The indexing method to use. Options include:
  • IndexingMethod.Standard - Full LLM-based extraction
  • IndexingMethod.NLP - NLP + LLM hybrid approach
Can be specified as an enum value or string.
is_update_run
bool
default:"False"
Whether this is an incremental update run. Set to True to update an existing index with new documents rather than rebuilding from scratch.
callbacks
list[WorkflowCallbacks] | None
default:"None"
A list of callback objects to receive pipeline lifecycle events. Use this to monitor indexing progress, handle errors, or implement custom logging.
additional_context
dict[str, Any] | None
default:"None"
Additional context to pass to the pipeline. This dictionary is accessible in the pipeline state under the additional_context key and can be used to pass custom data to pipeline workflows.
verbose
bool
default:"False"
Enable verbose logging output. When True, detailed logging information will be printed to the console and written to log files.
input_documents
pd.DataFrame | None
default:"None"
Override the default document loading and parsing. Supply your own pandas DataFrame of documents to index instead of loading from the configured input source.The DataFrame should have columns matching the expected document schema.

Returns

results
list[PipelineRunResult]
A list of pipeline run results, one for each workflow executed. Each result contains:
  • workflow - The name of the workflow that was executed
  • result - The workflow output data
  • error - Any error that occurred (None if successful)
  • errors - List of all errors encountered

Example: Basic indexing

Example: Incremental update

Example: Custom document input

Example: Monitoring with callbacks

Output files

The build_index function produces several output files in the configured output directory:
  • entities.parquet - Extracted entities with descriptions and metadata
  • relationships.parquet - Relationships between entities
  • communities.parquet - Hierarchical community structure
  • community_reports.parquet - Summary reports for each community
  • text_units.parquet - Chunked text units from source documents
  • covariates.parquet - Extracted claims and covariates (if enabled)
These files can be loaded and used with the query API:

Configuration

The GraphRagConfig object controls all aspects of indexing:
See the configuration guide for details on available settings.

Error handling

The build_index function returns results even if some workflows fail. Check the error field in each result: