Skip to content
Snippets Groups Projects
Commit 45e6ab58 authored by Francé Wilke's avatar Francé Wilke
Browse files

OpenSearch - Add checks for the flattened search tag

parent fdcd4dc6
Branches
Tags v1.132.0
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
......@@ -195,6 +201,7 @@ func structMappingProperties(structType reflect.Type) (map[string]MappingPropert
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment