fix(search): validate hybrid search query text

This commit is contained in:
zhangzherui
2026-07-23 06:32:30 +08:00
committed by lyingbug
parent 97bcca21c6
commit 7fde37eeeb
6 changed files with 146 additions and 0 deletions
+5
View File
@@ -302,6 +302,11 @@ func (h *KnowledgeBaseHandler) HybridSearch(c *gin.Context) {
c.Error(apperrors.NewBadRequestError("Invalid request parameters").WithDetails(err.Error()))
return
}
precomputedVectorOnly := len(req.QueryEmbedding) > 0 && req.DisableKeywordsMatch && !req.DisableVectorMatch
if strings.TrimSpace(req.QueryText) == "" && !precomputedVectorOnly {
_ = c.Error(apperrors.NewBadRequestError("query_text is required"))
return
}
logger.Infof(ctx, "Executing hybrid search, knowledge base ID: %s, query: %s, effectiveTenantID: %d",
secutils.SanitizeForLog(id), secutils.SanitizeForLog(req.QueryText), effectiveTenantID)