将json发送到弹性搜索时出错,当我转储json的错误时

时间:2017-02-10 05:46:36

标签: python elasticsearch

我通过将josn发送到弹性搜索来将数据上传到弹性搜索服务器,它工作正常,但在某些字符上,例如\它会出错,当我在json中发送反斜杠时,&如果我转储响应的json它会给出错误

"{"error": {"caused_by": {"reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes", "type": "not_x_content_exception"}, "reason": "failed to parse", "root_cause": [{"reason": "failed to parse", "type": "mapper_parsing_exception"}], "type": "mapper_parsing_exception"}, "status": 400}"

我的josn字符串是,

"{

"first_name":"muhammad irfan",

"middle_name": "",

"last_name":"ulhaq choudhary",

"address":"H,no,197,St,no. 157. G-9\\4",

"city":"Islamabad",

"phone_number1":"",

"phone_number2":"",

"phone_number3":"",

"gender":"M",

"updation_time":"0000-01-01",

"country_id":"1"
}
"

1 个答案:

答案 0 :(得分:0)

我不知道您使用的是哪个包。 但您可以尝试使用\\\\代替\\