我有一个shell脚本来创建弹性搜索中document types
之一的映射。
我的弹性搜索索引是bits
,我的文档类型是nts
,我正在尝试为long
类型的文档中的3个JSON密钥分配类型nts
即NT
,XT
和YT
。
#!/bin/bash
curl -XPUT 'http://localhost:9200/bits/nts/_mapping' -d '
{
"events" : {
"dynamic" : "strict",
"properties" : {
"NT" : {
type : "long"
},
"XT" : {
type : "long"
},
"YT" : {
type : "long"
}
}
},
}'
如果我运行上面的bash脚本,我会收到以下错误。
{"error":"ElasticsearchParseException[Failed to parse content to map]; nested: JsonParseException[Unexpected character ('}' (code 125)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: org.elasticsearch.common.compress.lzf.LZFCompressedStreamInput@6d7702cc; line: 17, column: 6]]; ","status":400}
答案 0 :(得分:3)
删除最后一个逗号并制作如下代码
curl -XPUT 'http://localhost:9200/bits/nts/_mapping' -d '
{
"events" : {
"dynamic" : "strict",
"properties" : {
"NT" : {
type : "long"
},
"XT" : {
type : "long"
},
"YT" : {
type : "long"
}
}
}
}'