首页 > 解决方案 > AWS。通过 Glue 将数据从 S3 写入 Elasticsearch

问题描述

我有一个与 Glue 相关的问题。我当前的任务是从 S3 读取数据并将其写入 Elastisearch(在 AWS 上)。我必须使用胶水。Glue 支持从 S3 读取作为源,但不能使用 Elasticsearch 作为目标。我的问题是如何以最少的努力将数据从 Glue 写入 Elasticsearch?

标签: amazon-web-serviceselasticsearchamazon-s3aws-glue

解决方案


如果必须使用glue,您可以简单地利用glue 编写python 代码,而无需利用spark。将“type”配置为“python shell”的新作业。编写 python 代码,您现在可以利用 boto3 库来访问您在 S3 中的文件:

s3 = boto3.client('s3')

检索到要上传到弹性搜索的内容后,您可以使用发布请求将文档上传到弹性搜索:

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

请参阅下面的将流数据从 Amazon S3 加载到 Amazon ES部分中的 AWS 文档。 “将流数据加载到 Amazon Elasticsearch Service”


推荐阅读