RAGFlowConfig config = RAGFlowConfig.builder()
// === Connection Configuration (Required) ===
.apiKey("ragflow-your-api-key") // RAGFlow API Key
.baseUrl("http://address") // RAGFlow service address (Required)
// === Dataset/Document Configuration (At least one required) ===
.addDatasetId("datasetId1")
.addDatasetId("datasetId2") // Supports multiple datasets
// Or batch set: .datasetIds(List.of("id1", "id2"))
// === Document Filtering (Optional, limits search scope) ===
.addDocumentId("documentId1")
.addDocumentId("documentId2")
// Or batch set: .documentIds(List.of("doc1", "doc2"))
// Note: If only setting document_ids, ensure all documents use the same embedding model
// === Retrieval Configuration (Optional) ===
.topK(1024) // Number of chunks for vector computation, default 1024
.similarityThreshold(0.2) // Similarity threshold, range 0.0-1.0, default 0.2
.vectorSimilarityWeight(0.3) // Vector similarity weight, range 0.0-1.0, default 0.3
// (1 - weight) is term similarity weight
//=== Pagination Parameters ===
.page(1) // Page number, default 1
.pageSize(30) // Page size, default 30
// === Advanced Retrieval Features (Optional) ===
.useKg(false) // Knowledge graph multi-hop query, default false
.tocEnhance(false) // TOC-enhanced retrieval, default false
.rerankId("BAAI/bge-reranker-v2-m3@BAAI") // Rerank model ID (model name or hex UUID)
.keyword(false) // Keyword matching, default false
.highlight(false) // Highlight matched results, default false
.addCrossLanguage("en") // Add target language
// Or batch set: .crossLanguages(List.of("en", "zh", "ja"))
// === Metadata Filtering (Optional) ===
.metadataCondition(Map.of(
"logic", "and", // Logical operator: and or or
"conditions", List.of(
Map.of(
"name", "author", // Metadata field name
"comparison_operator", "=", // Comparison operator
"value", "Toby" // Filter value
),
Map.of(
"name", "date",
"comparison_operator", ">=",
"value", "2024-01-01"
)
)
))
// === HTTP Configuration (Optional) ===
.timeout(Duration.ofSeconds(30)) // HTTP timeout, default 30s
.maxRetries(3) // Max retries, default 3
.addCustomHeader("X-Custom-Header", "value") // Custom headers
.build();