ElasticSearch {"error":"MapperParsingException[failed to parse];JsonParseException[Unexpected charac

来源:互联网 发布:linux 建立用户 编辑:程序博客网 时间:2024/04/29 01:47

{"error":"MapperParsingException[failed to parse]; nested: JsonParseException[Un
expected character (''' (code 39)): expected a valid value (number, String, arra
y, object, 'true', 'false' or 'null')\n at [Source: [B@6b36b647; line: 1, column
: 2]]; ","status":400}curl: (6) Could not resolve host: John,last_name
curl: (6) Could not resolve host: Smith,age
curl: (6) Could not resolve host: 25,about
curl: (6) Could not resolve host: I love to go rock climbing,interests
curl: (3) [globbing] bad range in column 2


报错的原图如下:



本来是打算,安装书上的教程,学习 ElasticSearch ,然后新建文档的时候,用这个curl插件,新建文档的。
命令如下:
curl -XPUT http://localhost:9200/blog/article/1 -d '{"title": "New version of Elasticsearch released!", "content": "Version 1.0 released today!", "tags": ["announce", "elasticsearch", "release"] }'
但是一直报错。刚刚开始,我发现是书上的json对象少了个双引号,然后给补上去之后,还是一样的问题,还是报错。然后检查json也是没问题的,但是还是不行。



我同桌的电脑是mac,然后我就把命令发给他,他在mac上执行了一下,OK,没有报错。



我就郁闷了,什么情况,mac的命令行怎么就可以呢!
然后查了下,在 Stack Overflow 网站上看到个解决方法,找到原因,原来Windows的命令行对这个双引号的识别问题。
把上面的原来的命令修改为如下格式,就可以正常运行。
curl -XPUT "http://localhost:9200/blog/article/1" -d "{"""title""": """New version of Elasticsearch released!""", """content""": """Version 1.0 released today!""","""tags""":"""["announce", "elasticsearch", "release"]"""}"



上面的json对象,我又稍作修改,又加了个属性,值为字符串数组类型。也是可以正确执行的。






0 0