mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-28 11:48:10 +08:00
feat[Go]: implement datasets/<dataset_id>/index P/G (#16153)
### What problem does this PR solve? ``` POST: http://localhost:9384/api/v1/datasets/433b390c630411f1a13eab5f89540b2a/index?type=graph Output: { "code": 0, "data": { "task_id": "ff5a3546bafa49d794a9a050d99c4a52" }, "message": "success" } ``` --- ``` GET: http://localhost:9384/api/v1/datasets/433b390c630411f1a13eab5f89540b2a/index?type=graph Output: { "code": 0, "data": { "id": "ff5a3546bafa49d794a9a050d99c4a52", "doc_id": "graph_raptor_x", "from_page": 100000000, "to_page": 100000000, "task_type": "graphrag", "priority": 0, "begin_at": "2026-06-17T18:07:45+08:00", "process_duration": 4.108135, "progress": -1, "progress_msg": "18:07:45 created task graphrag\n18:07:47 Task has been received.\n18:07:49 [ERROR][Exception]: Model config not found: Qwen/Qwen3-235B-A22B@test@SILICONFLOW", "retry_count": 1, "digest": "f16fd067d5c92cec", "create_time": 1781690865552, "create_date": "2026-06-17T18:07:45+08:00", "update_time": 1781690869108, "update_date": "2026-06-17T18:07:49+08:00" }, "message": "success" } ``` ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -592,6 +592,74 @@ func (h *DatasetsHandler) RemoveTags(c *gin.Context) {
|
||||
jsonResponse(c, common.CodeSuccess, true, "success")
|
||||
}
|
||||
|
||||
// RunIndex Run an indexing task (graph/raptor/mindmap) for a dataset.
|
||||
func (h *DatasetsHandler) RunIndex(c *gin.Context) {
|
||||
user, errorCode, errorMessage := GetUser(c)
|
||||
if errorCode != common.CodeSuccess {
|
||||
jsonError(c, errorCode, errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
datasetID := strings.TrimSpace(c.Param("dataset_id"))
|
||||
if datasetID == "" {
|
||||
jsonError(c, common.CodeDataError, "dataset_id is required")
|
||||
return
|
||||
}
|
||||
|
||||
userID := strings.TrimSpace(user.ID)
|
||||
if userID == "" {
|
||||
jsonError(c, common.CodeDataError, "user_id is required")
|
||||
return
|
||||
}
|
||||
|
||||
indexType := strings.ToLower(strings.TrimSpace(c.Query("type")))
|
||||
data, code, err := h.datasetsService.RunIndex(userID, datasetID, indexType)
|
||||
if err != nil {
|
||||
jsonError(c, code, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
jsonResponse(c, common.CodeSuccess, data, "success")
|
||||
}
|
||||
|
||||
// TraceIndex Trace an indexing task (graph/raptor/mindmap) for a dataset.
|
||||
func (h *DatasetsHandler) TraceIndex(c *gin.Context) {
|
||||
user, errorCode, errorMessage := GetUser(c)
|
||||
if errorCode != common.CodeSuccess {
|
||||
jsonError(c, errorCode, errorMessage)
|
||||
return
|
||||
}
|
||||
|
||||
datasetID := strings.TrimSpace(c.Param("dataset_id"))
|
||||
if datasetID == "" {
|
||||
jsonError(c, common.CodeDataError, "dataset_id is required")
|
||||
return
|
||||
}
|
||||
|
||||
userID := strings.TrimSpace(user.ID)
|
||||
if userID == "" {
|
||||
jsonError(c, common.CodeDataError, "user_id is required")
|
||||
return
|
||||
}
|
||||
|
||||
indexType := strings.ToLower(strings.TrimSpace(c.Query("type")))
|
||||
result, code, err := h.datasetsService.TraceIndex(datasetID, userID, indexType)
|
||||
if err != nil {
|
||||
jsonError(c, code, err.Error())
|
||||
return
|
||||
}
|
||||
if result == nil {
|
||||
jsonResponse(c, common.CodeSuccess, map[string]interface{}{}, "success")
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"code": common.CodeSuccess,
|
||||
"data": result,
|
||||
"message": "success",
|
||||
})
|
||||
}
|
||||
|
||||
// ListMetadataFlattened handles GET /api/v1/datasets/metadata/flattened.
|
||||
// @Summary List flattened metadata for datasets
|
||||
// @Description Get flattened metadata for multiple datasets
|
||||
|
||||
Reference in New Issue
Block a user