<?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 Selecting data from MongoDB in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341712#M109641</link>
    <description>All, 
&lt;BR /&gt; I'm creating a job which will be extracting data from mongodb daily, mapping json doc to flat table and inserting that into mysql. 
&lt;BR /&gt;Problem: I have to pass start and end date ( taken from globalMap.get("start") and globalMap.get("end") ) dates to mongodb query. What component can I use to do that ? The problem with tmongodbRow component is it allows parameters , and let say i can create a javascript function with find query in it , but output document has to be mapped to a flat resultset. Unfortunately only tmongodbinput has this mapping ability. i can take fields from sub document and map them to a flat structure. BUT tmongodbinput does not allow parameters to be passed to a query. 
&lt;BR /&gt;I'm sure someone has faced this issue, i would really appreciate your response. 
&lt;BR /&gt;The solution ( sub optimal ) I've came up with is first use tmongodbrow and execute javascript function which extracts data and inserts it into a temporary mongodb collection, then next component tmongodbinput extracts all data and maps it into flat table. The problem with this approach is that db.insert(... ) in mongodb locks the database..... I would like to just run select from mongodb with "where" and avoid inserts.</description>
    <pubDate>Thu, 12 Sep 2013 22:46:03 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-09-12T22:46:03Z</dc:date>
    <item>
      <title>Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341712#M109641</link>
      <description>All, 
&lt;BR /&gt; I'm creating a job which will be extracting data from mongodb daily, mapping json doc to flat table and inserting that into mysql. 
&lt;BR /&gt;Problem: I have to pass start and end date ( taken from globalMap.get("start") and globalMap.get("end") ) dates to mongodb query. What component can I use to do that ? The problem with tmongodbRow component is it allows parameters , and let say i can create a javascript function with find query in it , but output document has to be mapped to a flat resultset. Unfortunately only tmongodbinput has this mapping ability. i can take fields from sub document and map them to a flat structure. BUT tmongodbinput does not allow parameters to be passed to a query. 
&lt;BR /&gt;I'm sure someone has faced this issue, i would really appreciate your response. 
&lt;BR /&gt;The solution ( sub optimal ) I've came up with is first use tmongodbrow and execute javascript function which extracts data and inserts it into a temporary mongodb collection, then next component tmongodbinput extracts all data and maps it into flat table. The problem with this approach is that db.insert(... ) in mongodb locks the database..... I would like to just run select from mongodb with "where" and avoid inserts.</description>
      <pubDate>Thu, 12 Sep 2013 22:46:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341712#M109641</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-12T22:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341713#M109642</link>
      <description>You can pass parameters to the query. Put your values from the globalMap as strings to your query: 
&lt;BR /&gt;"..... your query json expression...." + TalendDate.formatDate("yyyy-MM-dd", ((String) globalMap.get("start"))) + " .... continue with your json query ...."</description>
      <pubDate>Thu, 12 Sep 2013 23:01:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341713#M109642</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-12T23:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341714#M109643</link>
      <description>Thank you it worked like a charm.</description>
      <pubDate>Thu, 12 Sep 2013 23:57:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341714#M109643</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-09-12T23:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341715#M109644</link>
      <description>How did you manage to do it? 
&lt;BR /&gt;Right now I´m trying to do this query: "db.user_ban_entities.find({end_date: {$gte:ISODate()}})" that works perfectly in mongodb shell. 
&lt;BR /&gt;However including it in Talend Mongo Input results in mongodb.util.JSONParseException.</description>
      <pubDate>Fri, 11 Apr 2014 18:50:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341715#M109644</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-04-11T18:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341716#M109645</link>
      <description>Can someone please help me on passing date parameters to MongoDB through tMongoDBInput Component to retrieve values for a date range. 
&lt;BR /&gt;While passing the hardcoded value, its returning results. But while passing the same dates through context variable its not working. 
&lt;BR /&gt;with context variable:&amp;nbsp; 
&lt;BR /&gt;"{EchoTimeStamp : { $gte :{\"$date\":\"+context.StartDate+\"}, $lte :{\"$date\":\"+context.EndDate+\"}} }" 
&lt;BR /&gt;with hardcoded value:&amp;nbsp; 
&lt;BR /&gt;"{EchoTimeStamp : { $gte :{\"$date\":\"2014-12-08T00:00:00Z\"}, $lte :{\"$date\":\"2014-12-12T00:00:00Z\"}} }" 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MBDS.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/152495i8DFBF4DA9214C998/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MBDS.png" alt="0683p000009MBDS.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Wed, 07 Jan 2015 13:02:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341716#M109645</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-01-07T13:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341717#M109646</link>
      <description>I have same question, can someone please help. 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;Can someone please help me on passing date parameters to MongoDB through tMongoDBInput Component to retrieve values for a date range.&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;While passing the hardcoded value, its returning results. But while passing the same dates through context variable its not working.&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;with context variable:&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;"{EchoTimeStamp : { $gte :{\"$date\":\"+context.StartDate+\"}, $lte :{\"$date\":\"+context.EndDate+\"}} }"&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;with hardcoded value:&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;"{EchoTimeStamp : { $gte :{\"$date\":\"2014-12-08T00:00:00Z\"}, $lte :{\"$date\":\"2014-12-12T00:00:00Z\"}} }"&lt;/FONT&gt;&lt;/FONT&gt;</description>
      <pubDate>Mon, 09 Mar 2015 22:30:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341717#M109646</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-09T22:30:48Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341718#M109647</link>
      <description>&lt;BLOCKQUOTE&gt; 
 &lt;TABLE border="1"&gt; 
  &lt;TBODY&gt; 
   &lt;TR&gt; 
    &lt;TD&gt;I have same question, can someone please help.&lt;BR /&gt;&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;Can someone please help me on passing date parameters to MongoDB through tMongoDBInput Component to retrieve values for a date range.&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;While passing the hardcoded value, its returning results. But while passing the same dates through context variable its not working.&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;with context variable:&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;"{EchoTimeStamp : { $gte :{\"$date\":\"+context.StartDate+\"}, $lte :{\"$date\":\"+context.EndDate+\"}} }"&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;with hardcoded value:&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;"{EchoTimeStamp : { $gte :{\"$date\":\"2014-12-08T00:00:00Z\"}, $lte :{\"$date\":\"2014-12-12T00:00:00Z\"}} }"&lt;/FONT&gt;&lt;/FONT&gt;&lt;/TD&gt; 
   &lt;/TR&gt; 
  &lt;/TBODY&gt; 
 &lt;/TABLE&gt; 
&lt;/BLOCKQUOTE&gt; 
&lt;BR /&gt;Please use the below command in the query window to get it done. 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;"{EchoTimeStamp : { $gte :{$date:'"+context.StartDate+"'}, $lte :{$date:'"+context.EndDate+"'}} }"&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;Just you need to remove the escape&amp;nbsp;characters&amp;nbsp;and need to give a single quote on both sides of context variable.&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;If you need a work around for this also.You can use tmongoDBRow component and use the function window to write mongodb compatible commands to get it executed and furnish the resulset for you if Query is not working for you.&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt; 
&lt;FONT size="1"&gt;&lt;FONT face="Verdana, Helvetica, Arial, sans-serif"&gt;like&lt;/FONT&gt;&lt;/FONT&gt; 
&lt;BR /&gt;"var today = new Date(); 
&lt;BR /&gt;var yesterday = new Date(); 
&lt;BR /&gt;yesterday.setDate(today.getDate() - 1); 
&lt;BR /&gt;db.sessionLogs.find({ 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; created: { 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $gte: today, 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $lt: yesterday 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; } 
&lt;BR /&gt;});"</description>
      <pubDate>Wed, 06 May 2015 11:43:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341718#M109647</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2015-05-06T11:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341719#M109648</link>
      <description>Actually Mongo has ISO date format and if you pass string format of date to $date function then it should work. Only glitch is though $date function returns NULL if you dont pass date in proper string format. Sample query which I use is as below. This works perfectly fine. 
&lt;BR /&gt;"{lastModifiedDate:{$gte:{$date:'"+TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",(Date)context.lastRuntime)+"' }}}"</description>
      <pubDate>Tue, 16 Jun 2015 21:41:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341719#M109648</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-16T21:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341720#M109649</link>
      <description>Hi, 
&lt;BR /&gt;Im trying to use context variable in mongo query using mongodb input component 
&lt;BR /&gt;Eg:&amp;nbsp;"{'_createdAt': { $gte :{$date:'"+context.incrementaldate1+"'}}}" 
&lt;BR /&gt;but im getting error like Type mismatch : cannot convert from string to boolean 
&lt;BR /&gt;In the above query im just trying to extract data above a particular date 
&lt;BR /&gt;Pls guide me.....</description>
      <pubDate>Tue, 19 Jan 2016 11:16:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341720#M109649</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2016-01-19T11:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341721#M109650</link>
      <description>Hello, 
&lt;BR /&gt;I am getting a same error as&amp;nbsp;Chakravarthy. my query is&amp;nbsp; 
&lt;BR /&gt;"{'data.type': 'provider', '_id': { $gt: { '$oid': '" + Integer.toHexString(((int)Math.floor(new Date().getTime()/1000)) - 60*60) + "0000000000000000'}}}" 
&lt;BR /&gt;I get the&amp;nbsp;cannot convert from string to boolean error. I followed it to the Java code here is the problem: 
&lt;BR /&gt;if ("{'data.type': 'provider', '_id': { $gt: { '$oid': '"+ Integer.toHexString(((int) Math.floor(new Date() 
&lt;BR /&gt;.getTime() / 1000))- (60 * 60))+ "0000000000000000"+ "'}}}".matches(".*" + key&amp;nbsp;+ "*:.*"))&amp;nbsp; 
&lt;BR /&gt;So basically the java code gets generated such that there is a string in an if condition which will as predicted throw an error.&amp;nbsp; 
&lt;BR /&gt;Can someone help out with this? I haven't yet found a resource explaining this 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MPcz.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/157233iD1A564EF62DE3BC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MPcz.png" alt="0683p000009MPcz.png" /&gt;&lt;/span&gt;</description>
      <pubDate>Tue, 26 Apr 2016 22:40:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341721#M109650</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-04-26T22:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341722#M109651</link>
      <description>hi,
&lt;BR /&gt;I am trying to get the data of the previous date but i am getting the error in tmongodbinput component.What needs to be done to load only the previous day date using talend.</description>
      <pubDate>Wed, 16 Nov 2016 05:27:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341722#M109651</guid>
      <dc:creator>krengan21</dc:creator>
      <dc:date>2016-11-16T05:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting data from MongoDB</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341723#M109652</link>
      <description>&lt;P&gt;I have created a context variable .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data type is &lt;B&gt;String&lt;/B&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;String last_sync_timestamp= "2022-08-16T00:00:00.533Z" ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Query : &lt;/B&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{'timestamp': {$gt: {$date: '"+context.last_sync_timestamp+"'}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked absolutely fine for me in TOS 8.0.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 13:19:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Selecting-data-from-MongoDB/m-p/2341723#M109652</guid>
      <dc:creator>raowaqasakram</dc:creator>
      <dc:date>2022-08-16T13:19:52Z</dc:date>
    </item>
  </channel>
</rss>

