I have a file that contains JSON objects, one object per line. Following is an example of one (prettified) object. My intention is to do the following, in order to index the objects in ES:
cat foo.json | jq -c '. | {"index": {"_id": .sys_id, "_index": "test", "_type": "entry"}}, .' | curl -XPOST http://my.server.com:9200/_bulk --data-binary @-
Consider working.json
which contains the following object:
{
"sdk_insights": {
"sun": [
-1,
-1,
0,
-1,
-1,
-1,
0,
1,
-1,
0,
-1,
0,
-1
],
"age_value": "25-34"
},
"@timestamp": 1333375220000,
"sys_id": "9493-87c5"
}
Running the above command on working.json
does the trick and the object is indexed in ES. However, if I have non-working.json
which contains:
{
"sdk_insights": {
"sun": [
-1,
-1,
0,
-1,
-1,
-1,
0,
1,
-1,
0,
-1,
0,
-1
],
"wed": [
0,
0.5,
0,
0,
-1,
0,
0,
0.5,
0,
0,
0
],
"all_week": [
0.26,
0.094,
0.11,
0.15,
0.25,
0.18,
0.19,
0.23,
0.11,
0.19,
0.2,
0.26,
0.16,
0.13
],
"age_value": "25-34"
},
"@timestamp": 1333375220000,
"sys_id": "87c5-9493"
}
Then the magic is gone. I get the following error: {"took":18,"errors":true,"items":[{"index":{"_index":"test","_type":"entry","_id":"87c5-9493","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"illegal_argument_exception","reason":"mapper [sdk_insights.wed] of different type, current_type [long], merged_type [double]"}}}}]}
I understand that I have to fix something with the mapping, but I failed to do it. I would appreciate any kind of help. Thanks!