Helpers.bulk not inserting any data

i am trying to insert data into elasticsearch using elasticsearch-python-dsl api. I am getting data from one index, then i am performing operations on it and then inserting it into another index.

below is my code.

client = Elasticsearch(['IP_HERE'])
s = Search(using=client, index="firewall-*", doc_type = 'doc').filter('range', **{'@timestamp': {'gte': 'now-60m' , 'lt': 'now'}}).params(request_timeout=30)
response = s.execute()
#print(response)
dict_data = {}
try:
	for hit1 in s.scan():
		source_ip.append(hit1.to_dict().get('src_ip'))
		destination_ip.append(hit1.to_dict().get('dst_ip'))
		all_data.append(hit1.to_dict())

except Exception as e:
	result.append("not able to parse json data " + str(e))

# print(dict_data)
for i in range(len(all_data)):
	if all_data[i].get('src_ip') in new_data:
		print("1")
		result.append(all_data[i])
	# print("--")
	if all_data[i].get('dst_ip') in new_data:
		print("2")
		result.append(all_data[i])

jdata = ast.literal_eval(json.dumps(result)) 
print(json.dumps(jdata))
helpers.bulk(client,jdata, index='c2', doc_type='doc')

I have elasticsearch 6.x and i need to insert not more than 100 results. I am not getting any error using above code but it is not inserting any data either. Can anyone tell me whats wrong with my code?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.