Pentaho

 View Only

 mongoDB output in one single collection and document

  • Pentaho
  • Kettle
  • Pentaho
  • Pentaho Data Integration PDI
Simon Leuenberger's profile image
Simon Leuenberger posted 06-25-2020 15:19

I had create a collection in the mongoDB, but now the structure in these document is not what I expect.

 

Now it's like:

{

  "_id": {

    "$oid": "1"

  },

  "ttl": {

    "$numberLong": "180"

  },

  "last_updated": {

    "$numberLong": "1593096734"

  },

  "provider_id": "724",

  "data": {

    "stations": {

      "s_station_id": "286239",

      "s_name": "Street 1"

    }

  }

}

{

  "_id": {

    "$oid": "1"

  },

  "ttl": {

    "$numberLong": "180"

  },

  "last_updated": {

    "$numberLong": "1593096734"

  },

  "provider_id": "725",

  "data": {

    "stations": {

      "s_station_id": "286240",

      "s_name": "Street 2"

    }

  }

}

But it need to be like:

{

  "_id": {

    "$oid": "1"

  },

  "ttl": {

    "$numberLong": "180"

  },

  "last_updated": {

    "$numberLong": "1593096734"

  },

  "provider_id": "724",

  "data": {

    "stations": {

      "s_station_id": "286239",

      "s_name": "Street 1"

      "s_station_id": "286240",

      "s_name": "Street 2"

    }

  }

}

 

I modified the "mongo document path" include the "modifier operation" to $push but it doesn't work well.

Can somebody give me an advice, please. Thank you very much.

 

2020-06-25_17-18-09


#PentahoDataIntegrationPDI
#Kettle
#Pentaho
Simon Leuenberger's profile image
Simon Leuenberger

Maybe I found a solution but still not 100% perfect.

  • I took the url (which is a JSON url) directly as an output for the mongodb. So I just needed to make the url als an JSON File.

 

But now I've to enrich the JSON File (string) with more data. The problem is, that the new datafield musst be in die structure of de JSON. Can anybody help. Thank you.