Dynamic Template convert JSON object to Text

Is it possible to convert JSON object to Text using Dynamic Template?
My aim is to have all fields in this object property to be Text

I am not using Logstash, this is from AWS Cloudwatch log to AWS Elasticsearch Service.

I have here part of my template

"bindings": {
	"path_match": "properties.bindings.*",
	"match_mapping_type": "*",
	"match": "*",
	"mapping": {
		"type": "text",
		"fields": {
			"keyword": {
				"ignore_above": 256,
				"type": "keyword"
			}
		}
	}
}

I have gotten error on some fields for example

Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>nil, :_index=>"cwl-2020.05.22", :_type=>"_doc", :routing=>nil}, #<LogStash::Event:0x58ca9f05>], :response=>{"index"=>{"_index"=>"cwl-2020.05.22", "_type"=>"_doc", "_id"=>"RG0jVHIBuw9XhmjONWGk", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [properties.bindings.2] of type [text] in document with id 'RG0jVHIBuw9XhmjONWGk'. Preview of field's value: '{date=2020-05-22 09:10:32.207187, timezone=Asia/Kuala_Lumpur, timezone_type=3}'", "caused_by"=>{"type"=>"illegal_state_exception", "reason"=>"Can't get text on a START_OBJECT at 1:6223"}}}}}

Solved with using enabled mapping
I don't quite understand what it does, but I got the result I wanted.

"bindings": {
    "path_match": "properties.bindings.*",
    "match_mapping_type": "*",
    "match": "*",
    "mapping": {
        "type": "object",
        "enabled": false
    }
 }
2 Likes

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.