老师我用git学习es,参数涉及到中文的部分就说我编码有问题,看到,请解答下。

来源:9-7 使用laravel的Command实现搜索引擎索引和模版的建立

qq_狗猿_0

2018-08-01

如图:

http://img.mukewang.com/szimg/5b6085a30001913d13660119.jpg

命令:

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

}


如果反中文改成非中文就不会报错,截图

http://img.mukewang.com/szimg/5b6086ec0001eccd13530099.jpg

命令:

 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

}]

}

直接在浏览器输入不会出错:

http://img.mukewang.com/szimg/5b6087e60001369313600159.jpg

git编码:

http://img.mukewang.com/szimg/5b6088c700016d7502700068.jpg

老师麻烦在你空闲的时候解答下。

写回答

1回答

轩脉刃

2018-08-06

这个是你的MINGW64的控制台的编码问题,你在控制台输入的不是utf-8编码的中文,应该编码的操作系统的地方有好几个,https://blog.csdn.net/xujinyang/article/details/6956634 你可以参考这个试试,如果不行,你再试试在文本中写入中文,然后复制到控制台看看。

0
1
qq_狗猿_0
谢谢解答
2018-08-10
共1条回复

Laravel快速开发简书

Laravel最新特性结合Mysql异步消息队列、ElasticSearch搜索引擎、Debugbar调试利器开发简书

1218 学习 · 613 问题

查看课程