# Dynamic template - treat objects as strings?

**URL:** <https://discuss.elastic.co/t/dynamic-template-treat-objects-as-strings/12516>\
**Category:** Elasticsearch\
**Created:** [June 21, 2013, 10:04pm UTC](https://discuss.elastic.co/t/dynamic-template-treat-objects-as-strings/12516 "2013-06-21T22:04:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Myung](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daniel_myung/32/2042_2.png) [@Daniel\_Myung](https://discuss.elastic.co/u/Daniel_Myung)\
**Post date:** [June 21, 2013, 10:04pm UTC](https://discuss.elastic.co/t/dynamic-template-treat-objects-as-strings/12516/1 "2013-06-21T22:04:18Z")

</div>

Hi,

Is there a dynamic\_template setting, or a dynamic/object setting that can  
for type "object" be indexed as a searchable string blob?

Our structure looks like this:

{  
"doc\_type": "foo",  
"date\_received": "2013-01-01", # mapped as date  
"form": {  
"username": "dan",  
"timestart": "2013-01-01 11:58:00", #mapped as date  
"timeend": "2013-01-01 11:59:00", #mapped as date,  
"prop1": "lala",  
"prop2": "dada",  
"prop3": {  
"suba": "something",  
"subb": "anything",  
}  
}  
}

The issue with our data is that due to the it being user defined document  
structures, we don't know if someone will create "prop3" as a string or a  
date, or a mapping.

We've set date\_detection to False, but the possible nested objects have  
prevented us from indexing unknown properties (we have a common, system  
defined index for our known properties)

What we're wondering is can the dynamic\_template work to:

1: store objects like form.prop3 as a searchable string (knowing full well  
that it'd be difficult to search)

2: if we set store=True, can we ensure that form.prop3 will be in its  
original json format and not stringified?

My attempt at the dynamic template:

"dynamic\_templates": [  
{  
"object\_fields": {  
"match": "form.\*",  
"match\_mapping\_type": "object",  
"mapping": {  
"type": "string"  
}  
}  
}  
],  
doesn't seem to pick up any of the properties despite the mapping being set  
to dynamic=true for the form property.

Is what I'm asking for possible?

Thanks,

Dan

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:** [July 6, 2017, 2:29am UTC](https://discuss.elastic.co/t/dynamic-template-treat-objects-as-strings/12516/2 "2017-07-06T02:29:55Z")

</div>


