Probleme using bulk

Hello everyone, i'm new using elasticsearch,
i am trying to index a json file with bulk, but it doesn't work,
i use jq to have the good format :
cat monitor.json | jq -c '.[] | {"index": {"_index": "monitoring", "_type": "monitoring", "_id": .id}}, .'

this is the result :

{"index":{"_index":"monitoring","_type":"monitoring","_id":null}}
{"temperature":"47","cpu":"1","ramtotal":"925","ramlibre":"502","ramswap":"0","memoireutil":"21","ramutil":"423","hdmi":"0x40001","ping":"4","date":"2017-06-21"}

and when i try to add it with the following line :
cat monitor.json | jq -c '.[] | {"index": {"_index": "monitoring", "_type": "monitoring", "_id": .id}}, .' | curl --header "Content-Type:application/json" -XPOST localhost:9200/_bulk --data-binary @monitor.json

i get this error :
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [FIELD_NAME]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [FIELD_NAME]"},"status":400}

do you have an idea of what is the problem?

thank you!

Please format your code using </> icon as explained in this guide. It will make your post more readable.

Or use markdown style like:

```
CODE
```

I would not define id to null. I'd just keep setting it.
Not sure it's the problem here though.

May be reproduce with a sample script as explained in About the Elasticsearch category

thank tou, it works now!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.