我有一个 shell 脚本来创建到 Elasticsearch 中我的文档类型
之一的映射。
我的elasticsearch索引是bits
,我的文档类型是nts
,我尝试为文档中的3个JSON键分配类型long
类型 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}
最佳答案
删除最后一个逗号,使代码如下
curl -XPUT 'http://localhost:9200/bits/nts/_mapping' -d '
{
"events" : {
"dynamic" : "strict",
"properties" : {
"NT" : {
type : "long"
},
"XT" : {
type : "long"
},
"YT" : {
type : "long"
}
}
}
}'
关于bash - 无法更新 Elasticsearch 中的映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29502958/