# Dynamic Template convert JSON object to Text

**URL:** <https://discuss.elastic.co/t/dynamic-template-convert-json-object-to-text/234450>\
**Category:** Elasticsearch\
**Created:** [May 27, 2020, 3:38am UTC](https://discuss.elastic.co/t/dynamic-template-convert-json-object-to-text/234450 "2020-05-27T03:38:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![psteh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@psteh](https://discuss.elastic.co/u/psteh)\
**Post date:** [May 27, 2020, 3:38am UTC](https://discuss.elastic.co/t/dynamic-template-convert-json-object-to-text/234450/1 "2020-05-27T03:38:24Z")

</div>

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

```auto
"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

```auto
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"}}}}}

```

---

<div class="post-metadata">

**Author:** ![psteh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@psteh](https://discuss.elastic.co/u/psteh)\
**Post date:** [May 27, 2020, 6:31am UTC](https://discuss.elastic.co/t/dynamic-template-convert-json-object-to-text/234450/2 "2020-05-27T06:31:28Z")

</div>

Solved with using [enabled](https://www.elastic.co/guide/en/elasticsearch/reference/current/enabled.html) mapping  
I don't quite understand what it does, but I got the result I wanted.

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 24, 2020, 7:25am UTC](https://discuss.elastic.co/t/dynamic-template-convert-json-object-to-text/234450/4 "2020-06-24T07:25:25Z")

</div>

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