我是elasticsearch
的新手,当我尝试将一些数据输入索引时,我不确定为什么会收到此消息。我想创建自己的ID,因此我生成了自己的UUID。
我的索引存在:
$ curl {IP}:{PORT} / _ cat / indices?v 健康状况索引pri rep docs.count docs.deleted store.size pri.store.size 黄色开放示踪剂5 1 0 0 795b 795b 黄色开放.kibana 1 1 1 0 3.2kb 3.2kb
$ curl -XPUT http://{IP}:{PORT}/tracer/poster/b9d9fj2c-69ea-47f0-94e1-a6a3caecd097?pretty -d {"test": 1}
{
"error" : {
"root_cause" : [ {
"type" : "mapper_parsing_exception",
"reason" : "failed to parse"
} ],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse",
"caused_by" : {
"type" : "json_e_o_f_exception",
"reason" : "Unexpected end-of-input within/between Object entries\n at [Source: org.elasticsearch.common.io.stream.InputStreamStreamInput@572153d0; line: 1, column: 13]"
}
},
"status" : 400
}
答案 0 :(得分:1)
您只需要用单引号
包装JSON输入user@host ~ $ curl -XPUT http://localhost:9200/test/test/1?pretty -d {"test": 1}
{
"error" : {
"root_cause" : [ {
"type" : "mapper_parsing_exception",
"reason" : "failed to parse"
} ],
"type" : "mapper_parsing_exception",
"reason" : "failed to parse",
"caused_by" : {
"type" : "json_e_o_f_exception",
"reason" : "Unexpected end-of-input within/between Object entries\n at [Source: org.elasticsearch.common.io.stream.InputStreamStreamInput@370eef58; line: 1, column: 13]"
}
},
"status" : 400
}
curl: (3) [globbing] unmatched close brace/bracket in column 2
现在使用单引号:
user@host ~ $ curl -XPUT http://localhost:9200/test/test/1?pretty -d '{"test": 1}'
{
"_index" : "test",
"_type" : "test",
"_id" : "1",
"_version" : 1,
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"created" : true
}