I'm using ES2.3
create new index mapping with below command works.
curl -XPUT 'http://localhost:9200/megacorp' -d '
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"employee": {
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"age": {
"type": "integer"
},
"about": {
"type": "string"
},
"interests": {
"type": "string"
},
"join_time": {
"type": "date",
"format": "dateOptionalTime",
"index": "not_analyzed"
}
}
}
}
}
'
now i hope can use a json file to create same index. tmap.json file like below
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"employee": {
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"age": {
"type": "integer"
},
"about": {
"type": "string"
},
"interests": {
"type": "string"
},
"join_time": {
"type": "date",
"format": "dateOptionalTime",
"index": "not_analyzed"
}
}
}
},
"aliases": [ "source" ]
}
then i usr curl to create it.
curl -s -XPOST 'localhost:9200/megacorp' --data-binary @tmap.json
and
curl -XPUT 'http://localhost:9200/megacorp' -d @tmap.json
both above commands not working, get error like below.
{"error":{"root_cause":[{"type":"class_cast_exception","reason":"java.util.ArrayList cannot be cast to java.util.Map"}],"type":"class_cast_exception","reason":"java.util.ArrayList cannot be cast to java.util.Map"},"status":500}%
how to create index with curl and my json file? this is really confused me for long time.
can any body help me? thanks.