老师我用git学习es,参数涉及到中文的部分就说我编码有问题,看到,请解答下。
来源:9-7 使用laravel的Command实现搜索引擎索引和模版的建立

qq_狗猿_0
2018-08-01
如图:
命令:
curl -XPOST "http://localhost:9200/_analyze" -d '{"analyzer":"ik_max_word","text":"中华人民共和国"}'
结果:
{
"error": {
"root_cause": [{
"type": "illegal_argument_exception",
"reason": "Failed to parse request body"
}],
"type": "illegal_argument_exception",
"reason": "Failed to parse request body",
"caused_by": {
"type": "json_parse_exception",
"reason": "Invalid UTF-8 middle byte 0xd0\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@56084038; line: 1, column: 37]"
}
},
"status": 400
}
如果反中文改成非中文就不会报错,截图
命令:
curl -XPOST "http://localhost:9200/_analyze" -d '{"analyzer":"ik_max_word","text":"hello xiao jiejie"}'
结果:
{
"tokens": [{
"token": "hello",
"start_offset": 0,
"end_offset": 5,
"type": "ENGLISH",
"position": 0
}, {
"token": "xiao",
"start_offset": 6,
"end_offset": 10,
"type": "ENGLISH",
"position": 1
}, {
"token": "jiejie",
"start_offset": 11,
"end_offset": 17,
"type": "ENGLISH",
"position": 2
}]
}
直接在浏览器输入不会出错:
git编码:
老师麻烦在你空闲的时候解答下。
1回答
-
轩脉刃
2018-08-06
这个是你的MINGW64的控制台的编码问题,你在控制台输入的不是utf-8编码的中文,应该编码的操作系统的地方有好几个,https://blog.csdn.net/xujinyang/article/details/6956634 你可以参考这个试试,如果不行,你再试试在文本中写入中文,然后复制到控制台看看。
012018-08-10
相似问题