func getFieldNames()

in action/log/logadapter/elasticsearch.go [128:155]


func getFieldNames(properties map[string]interface{}, prefix string) []string {
	fieldNames := []string{}

	for fieldName, fieldValue := range properties {
		// Generate the full path for the current field
		fullName := fieldName
		if prefix != "" {
			fullName = prefix + "." + fieldName
		}

		// Check if the field contains a "fields" node
		if fieldMap, ok := fieldValue.(map[string]interface{}); ok {
			if fields, ok := fieldMap["fields"].(map[string]interface{}); ok {
				// If there is a "fields" node, iterate through its fields and add to the result
				for subField := range fields {
					fieldNames = append(fieldNames, fullName+"."+subField)
				}
			}

			// If the field contains nested "properties", recursively parse subfields
			if nestedProperties, ok := fieldMap["properties"].(map[string]interface{}); ok {
				fieldNames = append(fieldNames, getFieldNames(nestedProperties, fullName)...)
			}
		}
	}

	return fieldNames
}