Reputation: 467
I am trying to create mapping in Elasticsearch, however, it doesn't work. It seems to have some issues with {
. I cannot find the cause of it, in my opinion it seems fine. Could you help me?
curl -X PUT "localhost:9200/data?pretty" -H 'Content-Type: application/json' -d
'{
{
"settings":{
"number_of_shards":"1",
"number_of_replicas":"1"
},
"mappings":{
"properties":{
"data":{
"type":"nested",
"properties":{
"title":{
"type":"text"
},
"sources":{
"type":"keyword"
},
"flags":{
"type":"keyword",
"null_value":"NULL"
},
"steps":{
"type":"nested",
"properties":{
"Morning":{
"type":"nested",
"null_value":"NULL",
"properties":{
"name":{
"type":"text"
},
"link":{
"type":"keyword",
"null_value":"NULL"
},
"type":{
"type":"keyword",
"null_value":"NULL"
},
"ingredients":{
"type":"keyword",
"null_value":"NULL"
},
"flags":{
"type":"keyword",
"null_value":"NULL"
}
}
},
"Evening":{
"type":"nested",
"null_value":"NULL",
"properties":{
"name":{
"type":"text"
},
"link":{
"type":"keyword",
"null_value":"NULL"
},
"type":{
"type":"keyword",
"null_value":"NULL"
},
"ingredients":{
"type":"keyword",
"null_value":"NULL"
},
"flags":{
"type":"keyword",
"null_value":"NULL"
}
}
}
}
}
}
}
}
}
}
}'
I am getting this error:
{
"error" : {
"root_cause" : [
{
"type" : "parse_exception",
"reason" : "Failed to parse content to map"
}
],
"type" : "parse_exception",
"reason" : "Failed to parse content to map",
"caused_by" : {
"type" : "json_parse_exception",
"reason" : "Unexpected character ('}' (code 125)): was expecting double-quote to start field name\n at [Source: (byte[])\"{ \"settings\": { \"number_of_shards\": \"1\", \"number_of_replicas\": \"1\", }, \"mappings\": { \"properties\": { \"data\": { \"type\": \"nested\", \"properties\": { \"title\": { \"type\": \"text\" }, \"sources\": { \"type\": \"keyword\" }, \"flags\": { \"type\": \"keyword\", \"null_value\": \"NULL\" }, \"steps\": { \"type\": \"nested\", \"properties\": { \"Morning\": { \"type\": \"nested\", \"null_value\": \"NULL\", \"properties\": { \"name\": {\"type\": \"text\"}, \"link\": {\"type\": \"keyword\", \"null_value\": \"NULL\"}, \"type\": {\"type\": \"keyword\", \"null_value\": \"\"[truncated 444 bytes]; line: 1, column: 70]"
}
},
"status" : 400
}
Upvotes: 1
Views: 1092
Reputation: 217594
You have two opening curly braces {
and two closing curly braces }
, you need to remove one at the top and the other at the bottom
Upvotes: 2