【发布时间】:2019-11-27 14:37:02
【问题描述】:
我按照文章“使用 Amazon Rekognition 和 Amazon Athena 探索社交媒体上的图像”进行了操作,一切正常。
我的问题是:如何将数据流式传输到 elasticsearch 服务?
我尝试在函数中添加这段代码
import base64
import requests
from requests_aws4auth import AWS4Auth
host = '' # the Amazon ES domain, including https://
index = 'lambda-kine-index'
type = 'lambda-kine-type'
url = host + '/' + index + '/' + type + '/'
headers = { "Content-Type": "application/json" }
region = 'us-east-1' # e.g. us-west-1
service = 'es'
credentials = boto3.Session().get_credentials()
awsauth = AWS4Auth(credentials.access_key, credentials.secret_key, region, service, session_token=credentials.token)
# edit the function
r = requests.put(url + tweet['id'], auth=awsauth, json=json.dumps(sentiment_record), headers=headers)
函数下载自:
https://s3.amazonaws.com/aws-bigdata-blog/artifacts/EyeOfCustomer/labelimage.zip
问题是请求模块不是内置的。我不知道如何在这个函数中添加它。 但是我想知道在这种情况下是否有任何其他方法可以将数据添加到elasticsearch。
【问题讨论】:
-
尝试使用 -
from botocore.vendored import requests代替import requests
标签: amazon-web-services elasticsearch aws-lambda