Pan*_*mar 3 curl elasticsearch
我接受了来自elasticsearch教程的命令,
curl -XPUT "http://localhost:9200/movies/movie/1" -d" { "title": "The Godfather","director": "Francis Ford Coppola","year": 1972}"
Run Code Online (Sandbox Code Playgroud)
产生以下错误:
{
"error":"MapperParsingException[failed to parse]; nested: JsonParseException[Unrecognized token 'The': was expecting ('true', 'false' or 'null')
at [Source: [B@d809e3; line: 1, column: 27]]; ",
"status":400
}
curl: (6) Could not resolve host: Godfather,director
curl: (6) Could not resolve host: Ford
curl: (3) [globbing] unmatched close brace/bracket in column 19
Run Code Online (Sandbox Code Playgroud)
任何人都可以请求帮助,我需要做些什么来纠正这个错误?
pet*_*ter 11
问题是您对JSON对象内的属性和值以及要传递给curl的文档本身使用相同的引号.
改为运行此命令:
curl -XPUT "http://localhost:9200/movies/movie/1" -d '{
"title": "The Godfather",
"director": "Francis Ford Coppola",
"year": 1972
}'
Run Code Online (Sandbox Code Playgroud)
更新:
因为你在Windows上运行命令,上面的解决方案将无法工作,而你的答案可以在这里得到解答:
这个结果命令应该工作:
curl -X PUT "http://localhost:9200/movies/movie/1" -d "{
""title"": ""The Godfather"",
""director"": ""Francis Ford Coppola"",
""year"": 1972
}"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8317 次 |
| 最近记录: |