Creating custom default mappings

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.
For more options, visit https://groups.google.com/groups/opt_out.

Hi,

Take a look at dynamic templateshttp://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.
For more options, visit https://groups.google.com/groups/opt_out.