Skip to content
Snippets Groups Projects
Commit d5a1f6ad authored by Johan de Klerk's avatar Johan de Klerk
Browse files

Merge branch 'main' of gitlab.bob.co.za:bob-public-utils/bobgroup-go-utils

parents dbce8d60 45e6ab58
Branches
Tags
No related merge requests found
......@@ -194,14 +194,14 @@ type ApiLog struct {
}
type ApiLogRequest struct {
Headers map[string]string `json:"headers,omitempty"`
Headers map[string]string `json:"headers,omitempty"` // NOTE: Once we're on OpenSearch 2.7, we should add search:"flattened" here
QueryParameters map[string]string `json:"query_parameters,omitempty"`
BodySize int `json:"body_size" search:"long"` // set even when body is truncated/omitted
Body string `json:"body,omitempty"` // json body as a string
}
type ApiLogResponse struct {
Headers map[string]string `json:"headers,omitempty"`
Headers map[string]string `json:"headers,omitempty"` // NOTE: Once we're on OpenSearch 2.7, we should add search:"flattened" here
BodySize int `json:"body_size"` // set even when body is truncated/omitted
Body string `json:"body,omitempty"` // json content as a string
}
......@@ -170,6 +170,12 @@ func structMappingProperties(structType reflect.Type) (map[string]MappingPropert
fieldMapping = MappingProperty{
Properties: subStructProperties,
}
} else if structField.Type.Kind() == reflect.Map {
// For maps, we only want to map if we specified "flattened" in the search tag
// If we did not specify the tag, we want to just continue without mapping
if structField.Tag.Get("search") != "flattened" {
continue
}
} else {
// fieldMapping = MappingProperty{Type: "text"}
// unknown value type... we do not specify mapping and let it use dynamic mapping
......@@ -194,6 +200,9 @@ func structMappingProperties(structType reflect.Type) (map[string]MappingPropert
case "object":
fieldMapping.Type = "object"
fieldMapping.Enabled = false
case "flattened":
// NOTE: This is only supported from OpenSearch 2.7 and onwards
fieldMapping.Type = "flat_object"
case "-":
// do not include in mapping
skip = true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment