<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Read list from MongoDB collection in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Read-list-from-MongoDB-collection/m-p/2318084#M88458</link>
    <description>&lt;P&gt;Hi, I have this collection in MongoDB of users, and different twitter followers across the time&lt;/P&gt; 
&lt;PRE&gt;&amp;gt; db.persons.find().pretty()&lt;BR /&gt;{&lt;BR /&gt;	"_id" : ObjectId("5665a4b75d25764fa615ac5d"),&lt;BR /&gt;	"name" : "Phillip Parker",&lt;BR /&gt;	"screen_name" : "PhilP",&lt;BR /&gt;	"social_networks" : {&lt;BR /&gt;		"twitter" : {&lt;BR /&gt;			"followers" : [&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-10-17T12:00:47Z"),&lt;BR /&gt;					"value" : 125&lt;BR /&gt;				},&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-10-19T05:17:51Z"),&lt;BR /&gt;					"value" : 129&lt;BR /&gt;				},&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-11-01T17:20:22Z"),&lt;BR /&gt;					"value" : 135&lt;BR /&gt;				},&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-11-04T14:13:26Z"),&lt;BR /&gt;					"value" : 137&lt;BR /&gt;				}&lt;BR /&gt;			]&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;I'm trying to read it using a tMongoDBInput component to get these rows&lt;/P&gt; 
&lt;PRE&gt;"Phillip Parker","PhilP","2015-10-17T12:00:47Z",125&lt;BR /&gt;"Phillip Parker","PhilP","2015-10-19T05:17:51Z",129&lt;BR /&gt;"Phillip Parker","PhilP","2015-11-01T17:20:22Z",135&lt;BR /&gt;"Phillip Parker","PhilP","2015-11-04T14:13:26Z",137&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;How must I configure tMongoDBInput or Talend to get data in this format?&lt;BR /&gt;&lt;BR /&gt;PS: The objective when this format is achieved, is to add in a tMap a month field (yyyy-mm or a relative month from another date) from the date field, and aggregate by user+month, choosing the max() number of followers of the month, that is, generate this result (2 documents in this example) in a new collection&lt;/P&gt; 
&lt;PRE&gt;&amp;gt; db.persons_aggr.find().pretty()&lt;BR /&gt;{&lt;BR /&gt;	"_id" : ObjectId("5665a8df5d25764fa615ac5e"),&lt;BR /&gt;	"name" : "Phillip Parker",&lt;BR /&gt;	"screen_name" : "PhilP",&lt;BR /&gt;	"month" : "2015-10",&lt;BR /&gt;	"social_networks" : {&lt;BR /&gt;		"twitter" : {&lt;BR /&gt;			"followers" : 129&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;	"_id" : ObjectId("5665a8f05d25764fa615ac5f"),&lt;BR /&gt;	"name" : "Phillip Parker",&lt;BR /&gt;	"screen_name" : "PhilP",&lt;BR /&gt;	"month" : "2015-11",&lt;BR /&gt;	"social_networks" : {&lt;BR /&gt;		"twitter" : {&lt;BR /&gt;			"followers" : 137&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt;</description>
    <pubDate>Sat, 16 Nov 2024 10:55:11 GMT</pubDate>
    <dc:creator>czuriaga</dc:creator>
    <dc:date>2024-11-16T10:55:11Z</dc:date>
    <item>
      <title>Read list from MongoDB collection</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Read-list-from-MongoDB-collection/m-p/2318084#M88458</link>
      <description>&lt;P&gt;Hi, I have this collection in MongoDB of users, and different twitter followers across the time&lt;/P&gt; 
&lt;PRE&gt;&amp;gt; db.persons.find().pretty()&lt;BR /&gt;{&lt;BR /&gt;	"_id" : ObjectId("5665a4b75d25764fa615ac5d"),&lt;BR /&gt;	"name" : "Phillip Parker",&lt;BR /&gt;	"screen_name" : "PhilP",&lt;BR /&gt;	"social_networks" : {&lt;BR /&gt;		"twitter" : {&lt;BR /&gt;			"followers" : [&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-10-17T12:00:47Z"),&lt;BR /&gt;					"value" : 125&lt;BR /&gt;				},&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-10-19T05:17:51Z"),&lt;BR /&gt;					"value" : 129&lt;BR /&gt;				},&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-11-01T17:20:22Z"),&lt;BR /&gt;					"value" : 135&lt;BR /&gt;				},&lt;BR /&gt;				{&lt;BR /&gt;					"date" : ISODate("2015-11-04T14:13:26Z"),&lt;BR /&gt;					"value" : 137&lt;BR /&gt;				}&lt;BR /&gt;			]&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;I'm trying to read it using a tMongoDBInput component to get these rows&lt;/P&gt; 
&lt;PRE&gt;"Phillip Parker","PhilP","2015-10-17T12:00:47Z",125&lt;BR /&gt;"Phillip Parker","PhilP","2015-10-19T05:17:51Z",129&lt;BR /&gt;"Phillip Parker","PhilP","2015-11-01T17:20:22Z",135&lt;BR /&gt;"Phillip Parker","PhilP","2015-11-04T14:13:26Z",137&lt;/PRE&gt; 
&lt;P&gt;&lt;BR /&gt;How must I configure tMongoDBInput or Talend to get data in this format?&lt;BR /&gt;&lt;BR /&gt;PS: The objective when this format is achieved, is to add in a tMap a month field (yyyy-mm or a relative month from another date) from the date field, and aggregate by user+month, choosing the max() number of followers of the month, that is, generate this result (2 documents in this example) in a new collection&lt;/P&gt; 
&lt;PRE&gt;&amp;gt; db.persons_aggr.find().pretty()&lt;BR /&gt;{&lt;BR /&gt;	"_id" : ObjectId("5665a8df5d25764fa615ac5e"),&lt;BR /&gt;	"name" : "Phillip Parker",&lt;BR /&gt;	"screen_name" : "PhilP",&lt;BR /&gt;	"month" : "2015-10",&lt;BR /&gt;	"social_networks" : {&lt;BR /&gt;		"twitter" : {&lt;BR /&gt;			"followers" : 129&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;BR /&gt;{&lt;BR /&gt;	"_id" : ObjectId("5665a8f05d25764fa615ac5f"),&lt;BR /&gt;	"name" : "Phillip Parker",&lt;BR /&gt;	"screen_name" : "PhilP",&lt;BR /&gt;	"month" : "2015-11",&lt;BR /&gt;	"social_networks" : {&lt;BR /&gt;		"twitter" : {&lt;BR /&gt;			"followers" : 137&lt;BR /&gt;		}&lt;BR /&gt;	}&lt;BR /&gt;}&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Nov 2024 10:55:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Read-list-from-MongoDB-collection/m-p/2318084#M88458</guid>
      <dc:creator>czuriaga</dc:creator>
      <dc:date>2024-11-16T10:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: Read list from MongoDB collection</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Read-list-from-MongoDB-collection/m-p/2318085#M88459</link>
      <description>By executing an aggregate command, I get the dataset I was looking for 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;&amp;gt; db.persons.aggregate( [ &lt;BR /&gt; &amp;nbsp; { $unwind: '$social_networks.twitter.followers' },&lt;BR /&gt; &amp;nbsp; { $project : { _id: 0,&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;name: '$name',&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;screen_name:'$screen_name',&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;date:'$social_networks.twitter.followers.date',&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;value:'$social_networks.twitter.followers.value' } } ] )&lt;BR /&gt;&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-10-17T12:00:47Z"), "value" : 125 }&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-10-19T05:17:51Z"), "value" : 129 }&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-11-01T17:20:22Z"), "value" : 135 }&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-11-04T14:13:26Z"), "value" : 137 }&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;But this statement only works in the Mongo console. The tMongoDBInput only execute find(), and the tMongoDBRow doesn't generate an exit to be processed 
&lt;BR /&gt;If I user the same statement, with $out 
&lt;BR /&gt; 
&lt;PRE&gt;&amp;gt; db.persons.aggregate( [ &lt;BR /&gt; &amp;nbsp; { $unwind: '$social_networks.twitter.followers' },&lt;BR /&gt; &amp;nbsp; { $project : { _id: 0,&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;name: '$name',&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;screen_name:'$screen_name',&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;date:'$social_networks.twitter.followers.date',&lt;BR /&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;value:'$social_networks.twitter.followers.value' } },&lt;BR /&gt; &amp;nbsp; {$out:"persons_aggr"} ] )&lt;BR /&gt;&lt;BR /&gt;&amp;gt; db.persons_aggr.find({},{_id:0})&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-10-17T12:00:47Z"), "value" : 125 }&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-10-19T05:17:51Z"), "value" : 129 }&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-11-01T17:20:22Z"), "value" : 135 }&lt;BR /&gt;{ "name" : "Phillip Parker", "screen_name" : "PhilP", "date" : ISODate("2015-11-04T14:13:26Z"), "value" : 137 }&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;In the Mongo console works fine, a a new collection is created, but again, this statement doesn't work in the tMongoDBRow component</description>
      <pubDate>Tue, 08 Dec 2015 02:33:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Read-list-from-MongoDB-collection/m-p/2318085#M88459</guid>
      <dc:creator>czuriaga</dc:creator>
      <dc:date>2015-12-08T02:33:35Z</dc:date>
    </item>
  </channel>
</rss>

