aggregation query in tmongoDBInput

Five Stars

aggregation query in tmongoDBInput

Hi,

 

I used below query in tmongodbinnput and it worked fine.

"{'$group':{'_id' : {'name':'$product.name','id':'$product.onairId'}, 'total' : {'$max' : '$prgDate'}}}"

 

But now I am using 

"{'$unwind': {'path' : '$grid'}},{'$group' :{'_id':'$grid.product.name','total':{'$max':'$dealCreatedAt'}}"

 

and it is not throwing any error, but it is just unwinding and returning all documents instead of grouping them.

 

Can anyone please tell how to unwind an array of objects and then do a group and find max of something?

 

Regards

Ravinder


Accepted Solutions
Five Stars

Re: aggregation query in tmongoDBInput

I found the solution after many trials.

 

I just used 2 stages by specifically adding 2 stages in tmongoInput aggregation pipeline mode.

stage 1 : "{$unwind : {path : '$grid'}}"

stage 2 :  "{$group : {_id : '$grid.product.name','total': {$max : '$dealCreatedAt'}}}"

 

 

 

 


All Replies
Five Stars

Re: aggregation query in tmongoDBInput

I found the solution after many trials.

 

I just used 2 stages by specifically adding 2 stages in tmongoInput aggregation pipeline mode.

stage 1 : "{$unwind : {path : '$grid'}}"

stage 2 :  "{$group : {_id : '$grid.product.name','total': {$max : '$dealCreatedAt'}}}"

 

 

 

 

Four Stars

Re: aggregation query in tmongoDBInput

Hi when i try to run query:-

"{'$group':{'_id' : {'_wellname':'$_wellname','_datasetname':'$_datsetname','_variablename':'$_variablename'}, 'total' : {'$sum' : 1}}}"

 

i get only count ,all columns are blank in output file.

 

I want count by column name passed in my query