Hi All,
i have json data like this
json_data =
{ "title": "Rush", "year": 2013, "budget":500000, "earning":300000,"genere":"action"}
{ "title": "Jurrasic", "year": 2014,"budget":1500000, "earning":2300000,"genere":"action"}
{ "title": "Dr Strange", "year": 2022,"budget":2500000, "earning":5000000,"genere":"Sci-fi"}
{ "title": "Avatar", "year": 2009,"budget":1200000, "earning":6000000,"genere":"Sci-fi"}
in reality it should become like this
{ "index": { "_index": "index_name", "_id": "tt1979320" } }
{ "title": "Rush", "year": 2013, "budget":500000, "earning":300000,"genere":"action"}
{ "index": { "_index": "index_name", "_id": "tt1979321" } }
{ "title": "Jurrasic", "year": 2014,"budget":1500000, "earning":2300000,"genere":"action"}
{ "index": { "_index": "index_name", "_id": "tt1979322" } }
{ "title": "Dr Strange", "year": 2022,"budget":2500000, "earning":5000000,"genere":"Sci-fi"}
{ "index": { "_index": "index_name", "_id": "tt1979323" } }
{ "title": "Avatar", "year": 2009,"budget":1200000, "earning":6000000,"genere":"Sci-fi"}
I need to do bulk load using python client
I need help in writing the action to do bulk indexing
actions = [
{
"_op_type": 'index'
"_index": index_name,
"_id": # should come from json_data,
"_source": {
"any":"data" # should come from json_data
}
for count in range(0, 10) # this is just to get batch of 10 but not sure what is the right way
]
print(actions)
response = bulk(client,actions)
print(response)