This topic describes how to use DTS RAGFlow to build GraphRAG for AnalyticDB for PostgreSQL. This solution builds a knowledge graph from your knowledge base, enabling deep understanding and precise retrieval for complex relational queries—going beyond the limitations of traditional vector-based retrieval.
This feature is currently in invitational preview. If you need access, submit a ticket to contact us so we can enable it for you.
Business scenario
When working with knowledge bases that contain complex entity relationships and deep logical structures—such as financial risk control reports, multi-product technical manuals, or enterprise organizational charts—traditional retrieval-augmented generation (RAG) solutions based solely on vector similarity often fail to answer queries that require multi-step reasoning or relationship discovery. Examples include “Compare the pros and cons of Product A and Product B in Scenario C” or “List all team members related to Project X and the modules they are responsible for.” These questions require an understanding of the intrinsic connections between entities, not just surface-level text similarity.
GraphRAG enhances traditional vector retrieval by introducing a knowledge graph. It explicitly extracts and structures the hidden entities and relationships from unstructured text. This allows the system to locate a relevant subgraph through graph retrieval and provide large language models (LLMs) with richer, more logically coherent context, which significantly improves the response quality for complex, multi-hop queries.
Solution architecture
This solution combines the data processing capabilities of DTS RAGFlow with the graph analytics engine of AnalyticDB for PostgreSQL to create an end-to-end pipeline, from document ingestion and knowledge graph construction to intelligent Q&A.
Workflow:
Data ingestion and processing: Upload unstructured documents to the DTS RAGFlow knowledge base.
Knowledge extraction and storage:
RAGFlow automatically parses, chunks, and embeds the documents.
When GraphRAG is enabled, RAGFlow invokes knowledge extraction operators to extract subject-predicate-object (S-P-O) trituples from the text.
Both the embedded text chunks and the extracted knowledge graph data (entities and edges) are written into a specified AnalyticDB for PostgreSQL instance for unified storage.
Hybrid retrieval:
During retrieval testing or API-based queries, the system performs hybrid retrieval.
The query first runs vector retrieval to find relevant text chunks.
Simultaneously, the query runs graph retrieval in the AnalyticDB for PostgreSQL graph analytics engine to identify relevant entities and their associated subgraph.
Context enrichment and generation: The system submits both the vector-retrieved text chunks and the graph-retrieved subgraph as context to the LLM, which then generates the final answer using this enriched information.
Implementation steps
Step 1: Prepare the environment
Create an AnalyticDB for PostgreSQL instance.
The Milvus version must be 7.3 or later.
Enable the GraphRAG service by installing the required plug-in.
In DTS, create a RAGFlow knowledge base and configure the IP allowlist.
Step 2: Configure the knowledge base and enable GraphRAG
This step associates the DTS RAGFlow knowledge base with your AnalyticDB for PostgreSQL instance.
Go to the RAGFlow knowledge base list page for the destination region.
Log on to the Data Transmission Service (DTS) console.
In the navigation pane on the left, click Data preparation.
In the upper-left corner of the page, select the region where the data preparation instance resides.
Click the RAGFlow Knowledge Base tab.
Log on to RAGFlow.
In the Actions column of the target RAGFlow knowledge base, click Manage.
NoteYou can also click Log on to Knowledge Base in the Actions column and choose to log on over the internal or public network.
In the Endpoint section, click Log on with Public Endpoint or Log on with Internal Endpoint.
NoteTo access the RAGFlow knowledge base over the public network, you must enable a public endpoint for the instance.
On the logon page, enter the account's email and password, and then click Log on.
On the RAGFlow page, you can manage the knowledge base and perform other operations.
NoteFor information about the operations, see the official RAGFlow documentation.

Click Create Knowledge Base. On the creation page, enter a name and toggle the Enable GraphRAG switch.
NoteBefore you create a knowledge base, add an embedding model and an LLM under Model Provider, and then configure them in .
If you plan to use external models and LLMs in your DTS RAGFlow knowledge base, configure a NAT Gateway for the VPC where the knowledge base is located to allow outbound internet access.
Create an Internet NAT gateway: Go to the NAT Gateway – Internet NAT Gateway purchase page. During creation, ensure that you select the same VPC and vSwitch as your DTS RAGFlow knowledge base.
Configure a SNAT entry: Go to the Internet NAT Gateway page. In the Operation column of your target gateway, click Set SNAT, and then click Create SNAT Entry. Configure the parameters as follows:
SNAT Entry Granularity: VPC.
Select Elastic IP Address: Choose an EIP that provides public network access from the drop-down list.
Step 3: Upload documents and build the knowledge graph
In your newly created knowledge base, go to Dataset and click Add File to upload a local file.
After the upload is complete, RAGFlow automatically runs parsing, chunking, embedding, and other processing steps. Because GraphRAG is enabled, the system also performs knowledge extraction and writes the resulting entities and edges into the configured AnalyticDB for PostgreSQL instance, which completes the knowledge graph construction.

After processing is complete, the Knowledge Graph component appears in the navigation pane on the left, which lets you visually browse and validate the extracted entities and relationships.

Step 4: Retrieval testing
Run comparative tests to verify the effectiveness of GraphRAG across different query types.
Go to the Retrieval Test page of your knowledge base.
Scenario 1: Simple queries
For factual, straightforward queries, such as “What is RAG?”, the system relies primarily on vector retrieval to return the most relevant text chunks, regardless of whether GraphRAG is enabled.
Scenario 2: Complex queries
For complex queries that require an understanding of relationships between entities, such as “Compare the pros and cons of RAG and GraphRAG”, select Use GraphRAG.
The retrieval results include both relevant text chunks and a structured relational subgraph. This subgraph appears as a Markdown table that clearly lists the core entities involved in the query and their relationships, which gives the LLM structured context to generate more logical and insightful answers.
The returned subgraph uses the following format:
---- Entities ---- ,Entity,Description 0,entity1,description1 1,entity2,description2 ---- Relations ---- ,From Entity,To Entity,Description 0,source_entity1,target_entity1,description1 1,source_entity2,target_entity2,description2Example:

If you do not select Use GraphRAG, the retrieval results include only text chunks. Without structured relationship data, the LLM may fail to provide an accurate answer.