简体   繁体   English

AWS。 通过Glue将数据从S3写入Elasticsearch

[英]AWS. Write data from S3 to Elasticsearch through Glue

I have a question related to Glue.我有一个与 Glue 相关的问题。 My current task it read data from S3 and write it to Elastisearch (on AWS).我当前的任务是从 S3 读取数据并将其写入 Elastisearch(在 AWS 上)。 And I have to use Glue.我必须使用胶水。 Glue is supported read from S3 as source, but cannot use Elasticsearch as target.支持从 S3 读取 Glue 作为源,但不能使用 Elasticsearch 作为目标。 My question how can I write data from Glue to Elasticsearch with the least effort?我的问题是如何以最少的努力将数据从 Glue 写入 Elasticsearch?

If you must use glue , You can simply leverage glue to write python code without leveraging spark.如果您必须使用胶水,您可以简单地利用胶水编写 python 代码,而无需利用火花。 Configure a new job with the "type" as "python shell".将“type”配置为“python shell”的新作业。 Writing python code, you can now leverage boto3 library to access your files in S3:编写 python 代码,您现在可以利用 boto3 库访问 S3 中的文件:

s3 = boto3.client('s3')

After retrieving the you want to upload to elastic search, you can then use a post request to upload the document to elastic search:检索到要上传到弹性搜索的内容后,您可以使用发布请求将文档上传到弹性搜索:

r = requests.post(url, auth=awsauth, json=document, headers=headers)

Please see AWS documentation below in the Loading streaming Data into Amazon ES from Amazon S3 Section.请参阅下面的将流数据从 Amazon S3 加载到 Amazon ES部分中的 AWS 文档。 "Loading Streaming Data into Amazon Elasticsearch Service" “将流数据加载到 Amazon Elasticsearch 服务”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM