LightRAG icon

LightRAG

Index documents into a LightRAG Knowledge Graph (entity + relation extraction) stored in CosmosDB vCore, and run hybrid KG + vector queries.

Insert Chunks

AI-generated

Summary

Insert pre-chunked text documents into the LightRAG knowledge graph by extracting entities and relations with an LLM, embedding the data for vector search, and indexing it into a specified MongoDB database.

Inputs

  • Database Name or ID (required) — Select the MongoDB database where the LightRAG collections are stored, or specify a database name expression.
  • Document ID — Unique identifier for the document; optional. If empty, the node auto-generates an ID based on the content hash. Used for updates or deletes later.
  • KG Extract Text (required) — Text chunk sent to the language model for entity and relation extraction. Each input item represents one chunk; use expressions like ={{ $json.text }}.
  • Vector Text — Text embedded for vector search. If left empty, it defaults to the KG Extract Text.
  • Full-Text Search Text — Text indexed for MongoDB keyword search. If empty, it defaults to the KG Extract Text.
  • Stored Chunk Document — JSON document stored alongside the chunk. Use an expression for custom content or leave empty to store the full current item JSON.
  • Workspace Override — Override the workspace identifier from credentials to route documents to different knowledge bases.
  • Enable Gleaning — Run a second LLM pass to capture entities missed in the first extraction, increasing accuracy but doubling token usage.
  • Batch Processing — Options to control batch size and delay between batches to limit concurrent LLM or embedding calls.

Output shape

a list of JSON objects, each representing a processed document chunk.

For each processed chunk, returns an object including the document ID, workspace, and counts of inserted chunks, extracted entities, and relations. Processes input items in batches; supports error handling with paired item index. Document IDs auto-generated if not provided.

Examples

Example 1: You have an array of pre-chunked text documents and want to index them into a LightRAG knowledge graph stored in a CosmosDB vCore MongoDB instance. You provide each chunk's extraction text, optionally customize vector and full-text search texts, and supply document IDs or let the node generate them. The node runs entity and relation extraction on each chunk using an LLM, embeds the text for vector search, and indexes everything into the specified database. Batch processing options help manage rate limits.

Set Database Name or ID, provide KG Extract Text per chunk, supply Document ID or leave empty for auto-generation, optionally specify Vector Text, Full-Text Search Text, and Stored Chunk Document JSON, set Workspace Override if needed, enable Gleaning for better extraction accuracy, and configure batch size and delay as needed.

Links

Discussion