bash - 无法更新 Elasticsearch 中的映射

标签 bash elasticsearch

我有一个 shell 脚本来创建到 Elasticsearch 中我的文档类型之一的映射。

我的elasticsearch索引是bits,我的文档类型是nts,我尝试为文档中的3个JSON键分配类型long类型 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}

最佳答案

删除最后一个逗号,使代码如下

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/

相关文章:

python - 清除 usr/lib/python3.5/site-packages/后 DNF 和 YUM 不工作

python - 运行目录中的所有 Python 文件

elasticsearch - 对数组对象进行 Elasticsearch 匹配查询

elasticsearch - 使用Elasticsearch在Titan上进行有序遍历

java - 如何向 Elastic Transport Client 添加身份验证

bash - 映射两个文件中的名称并获取单个文件

python - linux bash脚本中的模块加载命令

mysql - bash脚本访问多个mysql数据库

elasticsearch - 如何等待 Elasticsearch 中的重建索引?

amazon-web-services - AWS Elasticsearch : How to move data from one index into another