【问题标题】:How to insert a json array into a mongodb collection in Apache Nifi using PutMongo?如何使用 PutMongo 将 json 数组插入 Apache Nifi 中的 mongodb 集合?
【发布时间】:2020-12-22 06:46:35
【问题描述】:

我正在尝试使用 Apache nifi 中的 Putmongo 处理器将 json 数组插入 mongodb。但我收到一个错误:

error: current bson type is an array and not a document

这是我的 json:

[{"Name":"computer","TotalRevenue":15000},
{"Name":"music","TotalRevenue":1500},
{"Name":"space","TotalRevenue":5000}][{"Name":"a rehman","company":"music","revenue":500},
{"Name":"bill gates","company":"computer","revenue":6000},
{"Name":"elon must","company":"space","revenue":5000},
{"Name":"john lenin","company":"music","revenue":1000},
{"Name":"steve jobs","company":"computer","revenue":9000}]

另外,我正在附加 Putmongo 配置

这是我的完整 Apache 流程:

GetFile CSV -> ConvertRecord to Json -> QueryRecord -> MergeContent -> PutMongo

【问题讨论】:

    标签: mongodb etl apache-nifi apache-nifi-registry


    【解决方案1】:

    PutMongo 不接受 JSON 对象数组。因此,我使用 SplitJson 处理器将数组拆分为单独的 JSON 对象。然后使用 MergeContent 处理器将其合并以获得所需的结果。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-13
      • 2018-03-07
      • 1970-01-01
      • 2011-07-19
      • 2023-03-13
      • 1970-01-01
      • 2022-01-04
      相关资源
      最近更新 更多