Six Stars

Read mongoDB request

Hi,

i want to read mongoDB request but it don't work, i have errors.

The mongoDB request is aggregate type and complex :

 

db.lines.aggregate([
{"$match" :{billrun:"201707", type:"flat"}},
{"$group" :{
"_id":{"billrun" : "$billrun", "compte" : "$aid", "service" :"$sid"},
"billrun":{"$max":"$billrun"},
"compte": {"$max":"$aid"},
"service":{"$max":"$sid"},
"totalAmount":{"$sum":"$aprice"} }},
{$project :{_id:1, "facture":'$billrun', "compte":'$compte', "service":"$service","totalAmount":'$totalAmount'}}]).map(function(doc){
return( doc.facture + ";" + doc.compte + ";" + doc.service + ";" + doc.totalAmount );
})

the request, in RoboMongo, returns a result like this : 

"201707;58718520;150091;49.67",
"201707;983491;27274;49.197"

 

job is easy : tMongoDBConnection(it work) ---> tMongoDBInput(error) ---> tLogRow

For surrond strings with single quotes, how can i write whitout error my request ? I tried this : but it dont work.

 

The request in "Aggregation Stages tab" line is :

"{'$match' :{billrun:'201707', type:'flat'}},{'$group' :{'_id':{'billrun' : '$billrun', 'compte' : '$aid', 'service' :'$sid'},'billrun':{'$max':'$billrun'},'compte': {'$max':'$aid'},'service':{'$max':'$sid'},'totalAmount':'$sum':'$aprice'} }},{$project :{_id:1, 'facture':'$billrun', 'compte':'$compte', 'service':'$service','totalAmount':'$totalAmount'}}"

I have "Index cannot be resolved", "syntax error on tokens, delete these tokens"

 

schema of tMongoDbInput component is : 

facture (dBColumn : facture) (string)

compte (dBColumn :compte) (string)

service (dBColumn :service) (string)

totalAmount(dBColumn :totalAmount) (string)

 

thanks

 

 

 

  • Big Data
  • Data Integration
2 REPLIES
Moderator

Re: Read mongoDB request

Hello,

Could you please post your component setting screenshots on forum which will be helpful for us to address your issue.

Please mask your sensitive data.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: Read mongoDB request

talendmongoDB.PNG

 

 

a screenshoot Smiley Happy