liv2hak
liv2hak

Reputation: 15010

Unable to update mapping in elastic search

I have a shell script to create a mapping to one of my document types in elastic search.

My elasticsearch index is bits and my document type is nts and I am trying to assign type long for 3 JSON keys in the document of type nts namely NT, XT and 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" 
                }
            }
        },
}'

If I run the above bash script, I get the following error.

{"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}

Upvotes: 2

Views: 3045

Answers (1)

rhozet
rhozet

Reputation: 572

Remove the last comma and make the code like this

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

}'

Upvotes: 3

Related Questions