Reputation: 31
I have to post some information to elastic search using python. My info looks like
{ "index": {"_type": "TestSuiteReport","_index": "testsuite"}}{"Driver Name": "","Run Mode": "","TestSuite_Starttime": "2016-10-0T14:20:09","TestSuite Link": "2016-10-20T14:20:09","Number Of Tests Passed": 491}
I was using curl for posting the data to my search server using the command
Curl -i -X PUT -k "http://serverip:5601/_bulk" --data-binary @filelocation.
Can somebody help me finding alternative way to implement this in python ?
Upvotes: 1
Views: 3805
Reputation: 31
I found python useful for this scenario and example to that is shared here. tryolabs.com/blog/2015/02/17/python-elasticsearch-first-steps. This could send your single json doc to elasticsearch.
Upvotes: -1
Reputation: 3859
Read the json data from your file. Use requests python library to post the json to your server
import requests
data = open('yourfile').read()
url = "http://serverip:5601/_bulk"
requests.post(url, data=data)
Upvotes: 2