diff --git a/api_logs/api-logs.go b/api_logs/api-logs.go index bfd4ad1f3eb87f61e0b5e90e13dd0ceba0a92927..e0e446d90bf3863722a2fecef111f9db1c7915c1 100644 --- a/api_logs/api-logs.go +++ b/api_logs/api-logs.go @@ -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"` - BodySize int `json:"body_size"` // set even when body is truncated/omitted - Body string `json:"body,omitempty"` // json content as a string + 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 } diff --git a/opensearch/time_series.go b/opensearch/time_series.go index 54015d2628a1ae05dd91ff30060b45ea6138440d..c2cff48815389b089496977af5bbdf625a71c34f 100644 --- a/opensearch/time_series.go +++ b/opensearch/time_series.go @@ -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