无法更新弹性搜索中的映射

时间:2015-04-07 23:07:29

标签: bash elasticsearch

我有一个shell脚本来创建弹性搜索中document types之一的映射。

我的弹性搜索索引是bits,我的文档类型是nts,我正在尝试为long类型的文档中的3个JSON密钥分配类型ntsNTXTYT

#!/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}

1 个答案:

答案 0 :(得分:3)

删除最后一个逗号并制作如下代码

curl -XPUT 'http://localhost:9200/bits/nts/_mapping' -d '
{
    "events" : {
        "dynamic" : "strict",
        "properties" : {
            "NT" : {
                    type : "long" 
             },
            "XT" : {
                    type : "long" 
             },
            "YT"  : {
                    type : "long" 
            }
        }
    }

}'