# Creating custom default mappings

**URL:** <https://discuss.elastic.co/t/creating-custom-default-mappings/14415>\
**Category:** Elasticsearch\
**Created:** [November 14, 2013, 6:34pm UTC](https://discuss.elastic.co/t/creating-custom-default-mappings/14415 "2013-11-14T18:34:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh\_Harrison](https://avatars.discourse-cdn.com/v4/letter/j/0ea827/32.png) [@Josh\_Harrison](https://discuss.elastic.co/u/Josh_Harrison)\
**Post date:** [November 14, 2013, 6:34pm UTC](https://discuss.elastic.co/t/creating-custom-default-mappings/14415/1 "2013-11-14T18:34:08Z")

</div>

Hi all,  
I have a varied data stream that may change without substantial or any  
warning from the source. I'd like to be able to make it so that if a key  
name contains the string "url", that key will be not\_analyzed. Is that  
possible to do with the config/default\_mapping.json?  
Basically, I want to be able to define in default\_mapping.json  
If not, can I define an explicit list of fields in default\_mapping.json?  
I tried the following and if I add a url field to a new index it's not  
marked as not\_analyzed.  
{  
"_default_" : {  
"url" : {"type":"string", "index":"not\_analyzed"}  
}  
}

I also tried the following  
{  
"_default_" : {},  
"url" : {"type":"string", "index":"not\_analyzed"}  
}  
which results in:  
org.elasticsearch.index.mapper.MapperParsingException: mapping must have  
the `type` as the root object  
at  
org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:261)  
at  
org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:169)  
at  
org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:387)  
at  
org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:195)  
at  
org.elasticsearch.index.mapper.MapperService.documentMapperWithAutoCreate(MapperService.java:416)  
at  
org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:319)  
at  
org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:211)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:533)  
at  
org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:418)  
at  
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
at  
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
at java.lang.Thread.run(Thread.java:744)

This error makes me think that I can't predefine fields in  
default\_mapping.json like I was hoping, is that accurate?

--  
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:** ![sina\_tamanna](https://avatars.discourse-cdn.com/v4/letter/s/a6a055/32.png) [@sina\_tamanna](https://discuss.elastic.co/u/sina_tamanna)\
**Post date:** [November 15, 2013, 2:02pm UTC](https://discuss.elastic.co/t/creating-custom-default-mappings/14415/2 "2013-11-15T14:02:26Z")

</div>

Hi,

Take a look at dynamic templates[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#\_dynamic\_templates](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-root-object-type.html#_dynamic_templates)  
.

On Thursday, November 14, 2013 7:34:08 PM UTC+1, Josh Harrison wrote:

> Hi all,  
> I have a varied data stream that may change without substantial or any  
> warning from the source. I'd like to be able to make it so that if a key  
> name contains the string "url", that key will be not\_analyzed. Is that  
> possible to do with the config/default\_mapping.json?  
> Basically, I want to be able to define in default\_mapping.json  
> If not, can I define an explicit list of fields in default\_mapping.json?  
> I tried the following and if I add a url field to a new index it's not  
> marked as not\_analyzed.  
> {  
> "_default_" : {  
> "url" : {"type":"string", "index":"not\_analyzed"}  
> }  
> }
> 
> I also tried the following  
> {  
> "_default_" : {},  
> "url" : {"type":"string", "index":"not\_analyzed"}  
> }  
> which results in:  
> org.elasticsearch.index.mapper.MapperParsingException: mapping must have  
> the `type` as the root object  
> at  
> org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:261)  
> at  
> org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:169)  
> at  
> org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:387)  
> at  
> org.elasticsearch.index.mapper.MapperService.merge(MapperService.java:195)  
> at  
> org.elasticsearch.index.mapper.MapperService.documentMapperWithAutoCreate(MapperService.java:416)  
> at  
> org.elasticsearch.index.shard.service.InternalIndexShard.prepareCreate(InternalIndexShard.java:319)  
> at  
> org.elasticsearch.action.index.TransportIndexAction.shardOperationOnPrimary(TransportIndexAction.java:211)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:533)  
> at  
> org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:418)  
> at  
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
> at  
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
> at java.lang.Thread.run(Thread.java:744)
> 
> This error makes me think that I can't predefine fields in  
> default\_mapping.json like I was hoping, is that accurate?

--  
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:06am UTC](https://discuss.elastic.co/t/creating-custom-default-mappings/14415/3 "2017-07-06T02:06:45Z")

</div>


