我接受了来自elasticsearch教程的命令,
curl -XPUT "http://localhost:9200/movies/movie/1" -d" { "title": "The Godfather","director": "Francis Ford Coppola","year": 1972}"
产生以下错误:
{ "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
任何人都可以请求帮助,我需要做些什么来纠正这个错误?
问题是您对JSON对象内的属性和值以及要传递给curl的文档本身使用相同的引号.
改为运行此命令:
curl -XPUT "http://localhost:9200/movies/movie/1" -d '{ "title": "The Godfather", "director": "Francis Ford Coppola", "year": 1972 }'
更新:
因为你在Windows上运行命令,上面的解决方案将无法工作,而你的答案可以在这里得到解答:
这个结果命令应该工作:
curl -X PUT "http://localhost:9200/movies/movie/1" -d "{ ""title"": ""The Godfather"", ""director"": ""Francis Ford Coppola"", ""year"": 1972 }"