Skip to content

Commit

Permalink
enhance: Add dsl log field for HybridSearch (#39584)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
congqixia committed Jan 26, 2025
1 parent c832793 commit d6a5a85
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/proxy/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"os"
"strconv"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -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()))
}

Check warning on line 3301 in internal/proxy/impl.go

View check run for this annotation

Codecov / codecov/patch

internal/proxy/impl.go#L3296-L3301

Added lines #L3296 - L3301 were not covered by tests

return builder.String()

Check warning on line 3303 in internal/proxy/impl.go

View check run for this annotation

Codecov / codecov/patch

internal/proxy/impl.go#L3303

Added line #L3303 was not covered by tests
}

func (node *Proxy) hybridSearch(ctx context.Context, request *milvuspb.HybridSearchRequest, optimizedSearch bool) (*milvuspb.SearchResults, bool, bool, error) {
metrics.GetStats(ctx).
SetNodeID(paramtable.GetNodeID()).
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit d6a5a85

Please sign in to comment.