Send JSON/XML/TXT/CSV files to ElasticSearch
You can do something like this :
curl -XPUT 'localhost:9200/twitter/tweet/1?pretty' -H 'Content-Type: application/json' -d'{ "user" : "kimchy", "post_date" : "2009-11-15T14:12:12", "message" : "trying out Elasticsearch"}'
The reason your request wasn't passing because you didnt specify the Content-Type as JSON. Plus, you should use PUT and not POST :) I copied this request from this documentation : https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html. Cheers.
The error you're seeing is due to the version of the Elastic Search being different. Before -XPUT
, add -H 'Content-Type: application/json'
Here is an example:
curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/