# Default field setting under a dynamic 'object'

**URL:** <https://discuss.elastic.co/t/default-field-setting-under-a-dynamic-object/7908>\
**Category:** Elasticsearch\
**Created:** [May 30, 2012, 8:51am UTC](https://discuss.elastic.co/t/default-field-setting-under-a-dynamic-object/7908 "2012-05-30T08:51:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zsombor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zsombor/32/2864_2.png) [@Zsombor](https://discuss.elastic.co/u/Zsombor)\
**Post date:** [May 30, 2012, 8:51am UTC](https://discuss.elastic.co/t/default-field-setting-under-a-dynamic-object/7908/1 "2012-05-30T08:51:14Z")

</div>

Hi,

Is it possible to define field mapping under a dynamic object for every  
field? I don't know in advance the name of the fields, but all should have  
been treated as string keywords. Imagine something similar for the mapping:

myCustomMapping {  
"fieldA": { "type": "string", "index": "analyzed", "analyzer": "keyword",  
"store":"yes" }  
"fieldB": { "type": "string", "index": "analyzed", "analyzer": "keyword",  
"store":"yes" }  
"fieldC": { "type": "string", "index": "analyzed", "analyzer": "keyword",  
"store":"yes" }  
"customFields": {  
"type": "object",  
"dynamic": "true",

- 

```
   "_defaultMapping" : {
          { "type": "string", "index": "analyzed", "analyzer": 

```

"keyword", "store":"yes" }  
}

- }  
}

I'm not sure, that my intentions are clear enough, I would like to search  
by any of the customFields as terms.  
Any suggestions how to achieve this, are welcomed.

Thanks  
Zsombor

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 3, 2012, 9:01am UTC](https://discuss.elastic.co/t/default-field-setting-under-a-dynamic-object/7908/2 "2012-06-03T09:01:27Z")

</div>

You can do that using dynamic templates in the root object mapper.

On Wed, May 30, 2012 at 10:51 AM, Zsombor [gzsombor@gmail.com](mailto:gzsombor@gmail.com) wrote:

> Hi,
> 
> Is it possible to define field mapping under a dynamic object for every  
> field? I don't know in advance the name of the fields, but all should have  
> been treated as string keywords. Imagine something similar for the mapping:
> 
> myCustomMapping {  
> "fieldA": { "type": "string", "index": "analyzed", "analyzer":  
> "keyword", "store":"yes" }  
> "fieldB": { "type": "string", "index": "analyzed", "analyzer":  
> "keyword", "store":"yes" }  
> "fieldC": { "type": "string", "index": "analyzed", "analyzer":  
> "keyword", "store":"yes" }  
> "customFields": {  
> "type": "object",  
> "dynamic": "true",
> 
> - 
> 
> ```
> "_defaultMapping" : {
> { "type": "string", "index": "analyzed", "analyzer":
> 
> ```
> 
> "keyword", "store":"yes" }  
> }
> 
> - }  
> }
> 
> I'm not sure, that my intentions are clear enough, I would like to search  
> by any of the customFields as terms.  
> Any suggestions how to achieve this, are welcomed.
> 
> Thanks  
> Zsombor

---

<div class="post-metadata">

**Author:** ![Zsombor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/zsombor/32/2864_2.png) [@Zsombor](https://discuss.elastic.co/u/Zsombor)\
**Post date:** [June 5, 2012, 3:54pm UTC](https://discuss.elastic.co/t/default-field-setting-under-a-dynamic-object/7908/3 "2012-06-05T15:54:28Z")

</div>

Thanks, it works !

Regards  
Zsombor

On Sunday, June 3, 2012 11:01:27 AM UTC+2, kimchy wrote:

> You can do that using dynamic templates in the root object mapper.
> 
> On Wed, May 30, 2012 at 10:51 AM, Zsombor [gzsombor@gmail.com](mailto:gzsombor@gmail.com) wrote:
> 
> > Hi,
> > 
> > Is it possible to define field mapping under a dynamic object for every  
> > field? I don't know in advance the name of the fields, but all should have  
> > been treated as string keywords. Imagine something similar for the mapping:
> > 
> > myCustomMapping {  
> > "fieldA": { "type": "string", "index": "analyzed", "analyzer":  
> > "keyword", "store":"yes" }  
> > "fieldB": { "type": "string", "index": "analyzed", "analyzer":  
> > "keyword", "store":"yes" }  
> > "fieldC": { "type": "string", "index": "analyzed", "analyzer":  
> > "keyword", "store":"yes" }  
> > "customFields": {  
> > "type": "object",  
> > "dynamic": "true",
> > 
> > - 
> > 
> > ```
> > "_defaultMapping" : {
> > { "type": "string", "index": "analyzed", "analyzer": 
> > 
> > ```
> > 
> > "keyword", "store":"yes" }  
> > }
> > 
> > - }  
> > }
> > 
> > I'm not sure, that my intentions are clear enough, I would like to search  
> > by any of the customFields as terms.  
> > Any suggestions how to achieve this, are welcomed.
> > 
> > Thanks  
> > Zsombor

---

<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, 3:25am UTC](https://discuss.elastic.co/t/default-field-setting-under-a-dynamic-object/7908/4 "2017-07-06T03:25:34Z")

</div>


