如何将生产的JSON密钥设置为MongoDB Atlas的文档_id

发布于 2025-02-01 04:50:42 字数 539 浏览 4 评论 0原文

我正在构建一个数据管道,在那里我通过KAFKA将刮擦数据发送到MongoDB Atlas(全部在云中,而不是本地)。

我用我的Contruent Kafka配置初始化了一个生产者P。然后,我从Internet中提取我列表中每个公司的WKN和ISIN。我以JSON格式将这些数据发送到Kafka。 请参阅此处:

p.produce(
            "wkns_and_isins",
            key=company,
            value=identification_numbers,
            callback=delivery_report,
        )

现在,当我将JSON数据发送到我的云管理的MongoDB地图集时,我想将JSON-KEY设置为文档“ _id”。因此,我正在使用MongoDB Atlas水槽连接器。 在MongoDB中,应该看起来像这样:

{
_id: 'Adidas',
value: 'XXX / XXX' 
}

它将如何工作?

I am building a data pipeline, where I am sending scraped data via Kafka to mongoDB Atlas (all in the cloud, not local).

I initialized a Producer p with my Confluent Kafka configs. Then I extract WKNs and ISINs of every company I have in my list from the internet. I am sending this data in JSON format to Kafka.
See here:

p.produce(
            "wkns_and_isins",
            key=company,
            value=identification_numbers,
            callback=delivery_report,
        )

Now I want to set the JSON-key as the document "_id" when I am sending the JSON data to my cloud-managed mongoDB Atlas. Therefore I am using the MongoDB Atlas Sink Connector.
In the mongoDB it should look like this:

{
_id: 'Adidas',
value: 'XXX / XXX' 
}

How will that work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文