Trying to create mapping under Elasticsearch 2 with the following command, but it fails:
POST /my_blog
{
"settings": {
"index" : {
"number_of_shards" : 10
}
},
"mappings": {
"post" : {
"_routing" : {
"required": false,
"path" : "post_date"
},
"properties": {
"user_id" :{
"type": "integer"
},
"post_text" : {
"type": "string"
},
"post_date": {
"type" : "date",
"format" : "YYYY-MM-DD"
}
}
}
}
}
Response:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [_routing] has unsupported parameters: [path : post_date]"
}
],
"type": "mapper_parsing_exception",
"reason": "mapping [post]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [_routing] has unsupported parameters: [path : post_date]"
}
},
"status": 400
}
It doesn't matter what field I choose for the path, integer/string or date, it always gives the same error reply (see above). Any ideas?
Take a look at the type meta-field changes in 2.0. What you're trying to do can't be done anymore.
You'll have to create the index like this:
POST /my_blog
{
"settings": {
"index" : {
"number_of_shards" : 10
}
},
"mappings": {
"post" : {
"_routing" : {
"required": false
},
"properties": {
"user_id" :{
"type": "integer"
},
"post_text" : {
"type": "string"
},
"post_date": {
"type" : "date",
"format" : "YYYY-MM-DD"
}
}
}
}
}
Then specify the routing in the query string of each indexed document, like:
PUT /my_blog/post/1?routing=2015-11-19
{
"user_id": 1,
"post_text": "Lorem ipsum",
"post_date": "2015-11-19"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With