From 5e96c5cae6add24c10f6b9c48d69006a901e9419 Mon Sep 17 00:00:00 2001 From: Jin Hai Date: Fri, 8 May 2026 20:25:14 +0800 Subject: [PATCH] Fix go cli: search on datasets (#14692) ### What problem does this PR solve? As title ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Signed-off-by: Jin Hai --- internal/cli/user_command.go | 6 +++--- internal/handler/chunk.go | 16 ++++++++-------- internal/router/router.go | 1 + 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/internal/cli/user_command.go b/internal/cli/user_command.go index 4adfaea488..6dbf84be25 100644 --- a/internal/cli/user_command.go +++ b/internal/cli/user_command.go @@ -498,7 +498,7 @@ func (c *RAGFlowClient) SearchOnDatasets(cmd *Command) (ResponseIf, error) { } payload := map[string]interface{}{ - "kb_id": datasetIDs, + "dataset_ids": datasetIDs, "question": question, "similarity_threshold": 0.2, "vector_similarity_weight": 0.3, @@ -506,11 +506,11 @@ func (c *RAGFlowClient) SearchOnDatasets(cmd *Command) (ResponseIf, error) { if iterations > 1 { // Benchmark mode - return raw result for benchmark stats - return c.HTTPClient.RequestWithIterations("POST", "/chunk/retrieval_test", "web", nil, payload, iterations) + return c.HTTPClient.RequestWithIterations("POST", "/datasets/search", "web", nil, payload, iterations) } // Normal mode - resp, err := c.HTTPClient.Request("POST", "/chunk/retrieval_test", "web", nil, payload) + resp, err := c.HTTPClient.Request("POST", "/datasets/search", "web", nil, payload) if err != nil { return nil, fmt.Errorf("failed to search on datasets: %w", err) } diff --git a/internal/handler/chunk.go b/internal/handler/chunk.go index d5967ff802..207edfee48 100644 --- a/internal/handler/chunk.go +++ b/internal/handler/chunk.go @@ -48,7 +48,7 @@ func NewChunkHandler(chunkService *service.ChunkService, userService *service.Us // @Produce json // @Param request body service.RetrievalTestRequest true "retrieval test parameters" // @Success 200 {object} map[string]interface{} -// @Router /v1/chunk/retrieval_test [post] +// @Router /api/v1/datasets/search [post] func (h *ChunkHandler) RetrievalTest(c *gin.Context) { user, errorCode, errorMessage := GetUser(c) if errorCode != common.CodeSuccess { @@ -304,13 +304,13 @@ func (h *ChunkHandler) UpdateChunk(c *gin.Context) { // Allowed fields for update (exclude ID fields) allowedFields := map[string]bool{ - "content": true, - "important_keywords": true, - "questions": true, - "available": true, - "positions": true, - "tag_kwd": true, - "tag_feas": true, + "content": true, + "important_keywords": true, + "questions": true, + "available": true, + "positions": true, + "tag_kwd": true, + "tag_feas": true, } for field := range rawBody { if field != "dataset_id" && field != "document_id" && field != "chunk_id" && !allowedFields[field] { diff --git a/internal/router/router.go b/internal/router/router.go index 9aa773098a..9569277f7d 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -175,6 +175,7 @@ func (r *Router) Setup(engine *gin.Engine) { datasets.GET("", r.datasetsHandler.ListDatasets) datasets.POST("", r.datasetsHandler.CreateDataset) datasets.DELETE("", r.datasetsHandler.DeleteDatasets) + datasets.POST("/search", r.chunkHandler.RetrievalTest) } // Search routes