Mapping for Nested JSON document in Elasticsearch

烈酒焚心 提交于 2019-12-25 13:31:02

问题


I have inserted the following JSON document into ElasticSearch.

{
    "AppName": "undefined",
    "CPUs": 8,
    "Errors": 0,
    "Forms": 2,
    "Group": "Unknown",
    "Language": "en-GB",
    "UserName": "user.name",
    "msgType": "234",
    "bent": "{
       \"ActiveT\": 6,
        \"ErrorM\": \"None\",
        \"Except\": \"None\",
        \"HadErr\": \"false\",
        \"HM\": 62,
        \"NHM\": 57,
        \"Parameter\": \"14331232706\",
        \"ReturnCode\": \"3050\",
        \"Severity\": \"info\",
        \"Timestamp\": \"Tue July0209: 58: 16NZST2015\",
        \"TId\": \"9891319709\",
        \"UserInfo\": \"Unknown\",

    }"

}

I want be able to plot graphs using the fields that are nested inside such as HM, NHM, ActiveT etc. My structure inside elastic search is as follows.

my_indes/my_doc_type/info_id

The info is given above as the JSON document.I am using the below mapping to map the nested JSON structure bent.

curl -XPOST localhost:9200/my_index/my_doc_type/_mapping?pretty -d '{
"events":{
        "_timestamp" : {
            "enabled" : true,
            "store" : true,
             "path" : "post_date",
            "format" : "yyyy-MM-dd HH:mm:ss"
        },
  "properties" : {
                "CPUs"  : {
                        "type" : "long",
                        "index": "not_analyzed"
                        },
                "Language"  : {
                        "type" : "string",
                        "index": "not_analyzed"
                        },
                "User"  : {
                        "type" : "string",
                        "index": "not_analyzed"
                        },

                "Forms"  : {
                        "type" : "long",
                        "index": "not_analyzed"
                        },
                "Errors"  : {
                        "type" : "long",
                        "index": "not_analyzed"
                        },
                "be_event" : {
                        "type" : "nested",
                        "properties" : {
                            "ActiveT" : { 
                                "type" : "long",  
                                "index" : "not_analyzed" 
                            },
                        }
                    }
            }
}

I get the following error.

"error" : "ElasticsearchParseException[Failed to parse content to map]; nested: JsonParseException[Unexpected character ('\"' (code 34)): was expecting comma to separate OBJECT entries\n at [Source: org.elasticsearch.common.compress.lzf.LZFCompressedStreamInput@c2f1e8d; line: 122, column: 19]]; ",
  "status" : 400

What is wrong with the mapping that I am using?

来源:https://stackoverflow.com/questions/30698466/mapping-for-nested-json-document-in-elasticsearch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!