From 6a07c7ce8802319595420263e07546316f08e68d Mon Sep 17 00:00:00 2001 From: chasingegg Date: Fri, 17 Jan 2025 21:01:57 +0800 Subject: [PATCH] enhance: add recalls response for restful api Signed-off-by: chasingegg --- internal/distributed/proxy/httpserver/constant.go | 1 + internal/distributed/proxy/httpserver/handler_v2.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/distributed/proxy/httpserver/constant.go b/internal/distributed/proxy/httpserver/constant.go index d56ce8e7ff38e..8aad40c4df80c 100644 --- a/internal/distributed/proxy/httpserver/constant.go +++ b/internal/distributed/proxy/httpserver/constant.go @@ -97,6 +97,7 @@ const ( HTTPReturnMessage = "message" HTTPReturnData = "data" HTTPReturnCost = "cost" + HTTPReturnRecalls = "recalls" HTTPReturnLoadState = "loadState" HTTPReturnLoadProgress = "loadProgress" diff --git a/internal/distributed/proxy/httpserver/handler_v2.go b/internal/distributed/proxy/httpserver/handler_v2.go index c034e65e096e0..168e3623e9610 100644 --- a/internal/distributed/proxy/httpserver/handler_v2.go +++ b/internal/distributed/proxy/httpserver/handler_v2.go @@ -1010,7 +1010,11 @@ func (h *HandlersV2) search(ctx context.Context, c *gin.Context, anyReq any, dbN HTTPReturnMessage: merr.ErrInvalidSearchResult.Error() + ", error: " + err.Error(), }) } else { - HTTPReturn(c, http.StatusOK, gin.H{HTTPReturnCode: merr.Code(nil), HTTPReturnData: outputData, HTTPReturnCost: cost}) + if len(searchResp.Results.Recalls) > 0 { + HTTPReturn(c, http.StatusOK, gin.H{HTTPReturnCode: merr.Code(nil), HTTPReturnData: outputData, HTTPReturnCost: cost, HTTPReturnRecalls: searchResp.Results.Recalls}) + } else { + HTTPReturn(c, http.StatusOK, gin.H{HTTPReturnCode: merr.Code(nil), HTTPReturnData: outputData, HTTPReturnCost: cost}) + } } } }