diff --git a/internal/datacoord/index_service.go b/internal/datacoord/index_service.go index 81f81ea4bd..6a2e3e8351 100644 --- a/internal/datacoord/index_service.go +++ b/internal/datacoord/index_service.go @@ -233,6 +233,12 @@ func (s *Server) parseAndVerifyNestedPath(identifier string, schema *schemapb.Co } nestedPath := identifierExpr.GetColumnExpr().GetInfo().GetNestedPath() + // escape the nested path to avoid the path being interpreted as a JSON Pointer + nestedPath = lo.Map(nestedPath, func(path string, _ int) string { + s := strings.ReplaceAll(path, "~", "~0") + s = strings.ReplaceAll(s, "/", "~1") + return s + }) return "/" + strings.Join(nestedPath, "/"), nil } diff --git a/internal/proxy/task_index.go b/internal/proxy/task_index.go index 68e7880430..8c010aca9c 100644 --- a/internal/proxy/task_index.go +++ b/internal/proxy/task_index.go @@ -19,6 +19,7 @@ package proxy import ( "context" "fmt" + "strings" "github.com/cockroachdb/errors" "go.uber.org/zap" @@ -806,10 +807,29 @@ func (dit *describeIndexTask) Execute(ctx context.Context) error { params = wrapUserIndexParams(metricType) } } + fieldName := field.Name + if field.IsDynamic { + jsonPath, err := funcutil.GetAttrByKeyFromRepeatedKV(common.JSONPathKey, indexInfo.GetIndexParams()) + if err != nil { + log.Ctx(ctx).Warn("failed to get json path for dynamic field", zap.Error(err)) + } else if jsonPath != "" { + // Skip leading "/" and find next "/" to get first path segment + trimmedPath := strings.TrimPrefix(jsonPath, "/") + slashIndex := strings.Index(trimmedPath, "/") + if slashIndex == -1 { + fieldName = trimmedPath // Use full remaining path if no more "/" + } else { + fieldName = trimmedPath[:slashIndex] + } + // Unescape JSON Pointer path: ~1 -> / and ~0 -> ~ + fieldName = strings.ReplaceAll(fieldName, "~1", "/") + fieldName = strings.ReplaceAll(fieldName, "~0", "~") + } + } desc := &milvuspb.IndexDescription{ IndexName: indexInfo.GetIndexName(), IndexID: indexInfo.GetIndexID(), - FieldName: field.Name, + FieldName: fieldName, Params: params, IndexedRows: indexInfo.GetIndexedRows(), TotalRows: indexInfo.GetTotalRows(),