in functions/load_es/app.py [0:0]
def downloadObject_InsertES(guid, Objectkey, fileType):
# Parsing event info
bucketName = MAIN_BUCKET_NAME
#S3 Object get data
obj = s3_cli.get_object(Bucket=bucketName, Key=Objectkey)
body = obj['Body'].read().decode('utf-8').replace('\\N', '\\n')
data = json.loads(body)
data = data[fileType]
actions = []
actions = [
{
'_op_type': 'index',
'_index': fileType.lower(),
'guid': guid,
'doc': entry
}
for entry in data
]
esClient = Elasticsearch(
hosts=[{'host': HOST, 'port': 443}],
use_ssl=True,
verify_certs=True,
http_auth=awsauth,
connection_class=RequestsHttpConnection)
helpers.bulk(esClient, actions)