问题
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