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

1 ACCEPTED SOLUTION

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'}}}"

 

 

 

 

1 REPLY
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'}}}"