zsh: parse error near `}'
最近按着教程在本地创建ES索引,报错:
curl -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/hotel -d{
"mappings": {
"properties": {
"title": {
"type": "text"
},
"city": {
"type" : "keyword"
},
"price": {
"type": "double"
}
}
}
}
zsh: parse error near `}'
原因是zsh将每行看作单独的命令,用单引号将-d参数值包住,修改如下
url -H "Content-Type: application/json" -XPUT http://127.0.0.1:9200/hotel -d'{
"mappings": {
"properties": {
"title": {
"type": "text"
},
"city": {
"type" : "keyword"
},
"price": {
"type": "double"
}
}
}
}'
{"acknowledged":true,"shards_acknowledged":true,"index":"hotel"}%
所以创建成功 查询索引结构,验证下:
curl -H "Content-Type: application/json" -XGET http://127.0.0.1:9200/hotel/_mapping
{"hotel":{"mappings":{"properties":{"city":{"type":"keyword"},"price":{"type":"double"},"title":{"type":"text"}}}}}
验证成功,问题解决。