ElasticSearch在Window系统下使用curl命令报错Compressor detection can only be called on some xcontent bytes or..

今天在学习ElasticSearch的,使用curl命令(win版本curl工具下载安装方式见
window系统下安装使用curl命令工具
)方式创建索引的时候,由于按照网上的教程,所以直接复制下来执行

curl -XPUT "http://localhost:9200/musics/music/1" -d'
{
    
    
   "title": "my heart will go on",
   "type": "English",
   "year": 1975
}'

发现报一大堆错误

{“error”:{“root_cause”:[{“type”:“mapper_parsing_exception”,“reason”:“failed to parse”}],“type”:“mapper_parsing_exception”,“reason”:“failed to parse”,“caused_by”:{“type”:“not_x_content_exception”,“reason”:“Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes”}},“status”:400}curl: (3) URL using bad/illegal format or missing URL curl: (6) Could not resolve host: English,year curl: (3) unmatched close brace/bracket in URL position 5: 1975}'

在这里插入图片描述百度上查了一下,很多人说是dns配置的问题(Linux系统),但我的是windows系统啊,然后换不同的关键字搜,总算找到了一个我想要看的答案,原来是因为windows命令行对引号的识别问题,只需要把上面命令中的"改为""",'改为"即可,如下所示

curl -XPUT "http://localhost:9200/musics/music/1" -d"
{
    
    
	"""title""": """my heart will go on""",
	"""type""": """English""",
	"""year""": 1975
}"

缩进后

curl -XPUT "http://localhost:9200/musics/music/1" -d"{"""title""": """my heart will go on""","""type""": """English""","""year""": 1975}"

再次执行,成功!
在这里插入图片描述记录下来,防止以后忘记

猜你喜欢

转载自blog.csdn.net/iwlnner/article/details/103506178