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
def exportTable(table_name):
query = "SELECT * FROM "+table_name
data = run(query)
jsondata = (json.dumps(data, indent=4, sort_keys=True, default=str))
print jsondata
print("Exporting MySQL table - "+table_name+" : "+str(len(data))+" rows")
for row in jsondata: #print row
res = es.bulk(index = "test8", body = row, refresh = True)
print (res)
I get below as output:
elasticsearch.exceptions.RequestError: TransportError(400, u'illegal_argument_exception', u'Malformed action/metadata line [1], expected START_OBJECT but found [START_ARRAY]')
Thanks for your reply. My json output is like below. I'm trying to insert each data set into elastic search.
[
{
"action": "enter",
"example": "app~textbox~$username_editbox~enter~lbcleader1",
"idactions": 1,
"info": "It enters value on the web control like editbox description etc"
},
{
"action": "set",
"example": "app~textbox~$username_editbox~set~lbcleader1",
"idactions": 2,
"info": "It sets value on the web control like editbox description etc"
}
]
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.