使用xshell测试elasticsearch的ik分词报错问题

来源:互联网 发布:淘宝网买短款真丝旗袍 编辑:程序博客网 时间:2024/06/14 19:52

我的xshell是默认安装的,今天把ik分词安装好了,然后按照安装官方给的进行测试,

第一步

1.create a index

curl -XPUT http://localhost:9200/index
没问题


第二步

2.create a mapping

curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'{    "fulltext": {             "_all": {            "analyzer": "ik_max_word",            "search_analyzer": "ik_max_word",            "term_vector": "no",            "store": "false"        },        "properties": {            "content": {                "type": "string",                "store": "no",                "term_vector": "with_positions_offsets",                "analyzer": "ik_max_word",                "search_analyzer": "ik_max_word",                "include_in_all": "true",                "boost": 8            }        }    }}'

没问题


第三步

3.index some docs

curl -XPOST http://localhost:9200/index/fulltext/1 -d'{"content":"美国留给伊拉克的是个烂摊子吗"}'

出现问题了,这时候报错了,如下:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [content]"}],"type":"mapper_parsing_exception","reason":"failed to parse [content]","caused_by":{"type":"json_parse_exception","reason":"Invalid UTF-8 middle byte 0xc0\n at [Source: org.elasticsearch.common.io.stream.InputStreamStreamInput@324c601f; line: 2, column: 15]"}},"status":400}


出现error,也就是不成功了,看中间有关于UTF-8的,百度找了一圈没有答案,不过根据提示是和字符编码有问题,这时候我想到了xshell的字符编码,

于是去设置字符编码,如下图:



如上设置,再去测试,OK了!!!

0 0