From d6a5a85b27e1765e0a49179acdfd748651dc00fe Mon Sep 17 00:00:00 2001 From: congqixia Date: Sun, 26 Jan 2025 15:57:06 +0800 Subject: [PATCH] enhance: Add dsl log field for HybridSearch (#39584) The dsl fields are separated in sub request structs and cannot be easiliy printed before. This PR adds a log helper to print the dsl expressions of HybridSearchRequest. Signed-off-by: Congqi Xia --- internal/proxy/impl.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 0d5e98d9d4600..cafa76fb72869 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -22,6 +22,7 @@ import ( "fmt" "os" "strconv" + "strings" "sync" "time" @@ -3287,6 +3288,21 @@ func (node *Proxy) HybridSearch(ctx context.Context, request *milvuspb.HybridSea return rsp, err } +type hybridSearchRequestExprLogger struct { + *milvuspb.HybridSearchRequest +} + +// String implements Stringer interface for lazy logging. +func (l *hybridSearchRequestExprLogger) String() string { + builder := &strings.Builder{} + + for idx, subReq := range l.Requests { + builder.WriteString(fmt.Sprintf("[No.%d req, expr: %s]", idx, subReq.GetDsl())) + } + + return builder.String() +} + func (node *Proxy) hybridSearch(ctx context.Context, request *milvuspb.HybridSearchRequest, optimizedSearch bool) (*milvuspb.SearchResults, bool, bool, error) { metrics.GetStats(ctx). SetNodeID(paramtable.GetNodeID()). @@ -3339,6 +3355,7 @@ func (node *Proxy) hybridSearch(ctx context.Context, request *milvuspb.HybridSea zap.Any("OutputFields", request.OutputFields), zap.String("ConsistencyLevel", request.GetConsistencyLevel().String()), zap.Bool("useDefaultConsistency", request.GetUseDefaultConsistency()), + zap.Stringer("dsls", &hybridSearchRequestExprLogger{HybridSearchRequest: request}), ) defer func() {