Index template


(Mehtryx) #1

I've created the following template:

$ curl 'http://myserver:9200/_template/template_1' -d '
{
"template" : "*",
"order" : 0,
"settings" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
},
"analysis" : {
"analyzer" : {
"default" : {
"type" : "keyword"
}
}
},
"mappings" : {
"content" : {
"Abstract" : {
"type" : "string",
"index" : "analyzed"
},
"Title" : {
"type" : "string",
"index" : "analyzed"
},
"SubTitle" : {
"type" : "string",
"index" : "analyzed"
},
"Body" : {
"type" : "string",
"index" : "analyzed"
},
"CreatedOn" : { "type" : "date" },
"AvailableOn" : { "type" : "date" },
"PubDate" : { "type" : "date" },
"PublishedOn" : { "type" : "date" }
}
}
}}'

2 Questions.....

#1 is this an appropriate spot to define the analyzer (assuming its
want I want as default in my indexes) ?

#2 When I create a new index the mapping doesnt seem to apply, I try
the following:

$ curl -XPUT 'http://myserver:9200/testthetemplate'
{"ok":true,"acknowledged":true}

$ curl 'http://ec2-107-22-54-249.compute-1.amazonaws.com:9200/
testthetemplate/_mapping'
{"testthetemplate":{"content":{"properties":{}}}}

My template is blank...it sees the content type there but none of the
fields are defined....further (in case it needed me to populate...)
when I add data the mappings do not apply.

I'm using ES 0.18.2

Any help appreciated.


(Clinton Gormley) #2

Hi Mehtryx

On Tue, 2011-11-08 at 12:52 -0800, Mehtryx wrote:

I've created the following template:

Please gist these curl statements instead of pasting into the email.
See http://www.elasticsearch.org/help

$ curl 'http://myserver:9200/_template/template_1' -d '
{
"template" : "*",
"order" : 0,
"settings" : {
"number_of_shards" : 5,
"number_of_replicas" : 1
},
"analysis" : {
"analyzer" : {
"default" : {
"type" : "keyword"
}
}
},

The analysis section should be part of 'settings' - that's probably
throwing the mapping off.

clint


(Mehtryx) #3

The analysis section should be part of 'settings' - that's probably
throwing the mapping off.

clint

Thanks Clint, yeah I usually do and this time I didnt gist it sorry.

I moved it as per this gist (https://gist.github.com/1351621) and it
still doesnt seem to apply. If I create my index with the information
as is of course it is fine so for now I am doing this...but ultimately
I would have liked to use the template.

Keith


(Mehtryx) #4

ah....pebkac. I was missing "properties" {} arround my fields in the
mappings.

Sigh. Solved.

Thanks

On Nov 9, 9:40 am, Mehtryx ke...@benedicthome.com wrote:

The analysis section should be part of 'settings' - that's probably
throwing the mapping off.

clint

Thanks Clint, yeah I usually do and this time I didnt gist it sorry.

I moved it as per this gist (https://gist.github.com/1351621) and it
still doesnt seem to apply. If I create my index with the information
as is of course it is fine so for now I am doing this...but ultimately
I would have liked to use the template.

Keith


(system) #5