I'm able to read data from mysql and print in json format but unable to send json data to elastic search.
Below is my piece of code in python
query = "SELECT * FROM "+table_name
data = run(query)
jsondata = (json.dumps(data, indent=4, sort_keys=True, default=str))
print("Exporting MySQL table - "+table_name+" : "+str(len(data))+" rows")
for row in jsondata:
res = es.bulk(index = "test8", body = row, refresh = True)
I get below as output:
elasticsearch.exceptions.RequestError: TransportError(400, u'illegal_argument_exception', u'Malformed action/metadata line , expected START_OBJECT but found [START_ARRAY]')
What is in a row? Could you share one example ?
Thanks for your reply. My json output is like below. I'm trying to insert each data set into elastic search.
"info": "It enters value on the web control like editbox description etc"
"info": "It sets value on the web control like editbox description etc"
Thank you for reply. I'm new to concepts of elastic search and hence was trying with bulk.
Is there any best way to push data from mysql to elastic search using python. Can you please suggest.
Bulk API is the right way to do it. Just adapt your code to generate what the Bulk API is expecting.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.