[GODRIVER-1497] mongo-go-driver aggregate not apply $lookup Created: 26/Feb/20  Updated: 27/Oct/23  Resolved: 30/Mar/20

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: 1.3.0, 1.4.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Demon Brown Assignee: Divjot Arora (Inactive)
Resolution: Gone away Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

centos7,golang1.10/golang1.12


Attachments: PNG File image-2020-02-26-17-14-37-905.png     PNG File image-2020-02-26-17-19-46-519.png     PNG File image-2020-02-26-17-22-34-057.png    

 Description   

mongo-go-driver demo code:

 

response:

 

 

 

 

 

 

problem desc:

Hi, There are picture about problem  when I use mongo-go-driver aggregate $lookup ,I hope receive your tip soon, Thank you!

 



 Comments   
Comment by Divjot Arora (Inactive) [ 03/Mar/20 ]

Hi dingjiangnx@aliyun.com,

The stack trace you provided shows a panic inside a bson.M delcaration, which shouldn't be possible as bson.M is only a type definition for map[string]interface{}. Can you provide the collection names and some sample documents for each collection, as well as code that we can run outside of your existing application? If you have a Github account, the easiest way to provide code is through a Github gist (https://gist.github.com/). If not, you can write it in a standalone main.go file and attach it to your reply.

Thanks,

– Divjot

Comment by Demon Brown [ 26/Feb/20 ]

1. mongo shell command :

db.tb_isr_records.aggregate([\{$match:{app_id:"1005439786280841",ir_add_date:"20200115"}},\{$lookup:{from:"tb_isr_visitors", localField:"fb_uid", foreignField:"fb_uid", as: "res"}},\{$unwind:"$res"},\{$match:{app_id:"1005439786280841","res.iv_add_date":"20200114",ir_add_date:"20200115"}},\{$group:{_id:"$fb_uid"}},\{$group:{_id:0,counts:{$sum:1}}}]);

 

2. real mongo-go-driver aggregation content about $lookup: 

whereMap := bson.A{
bson.M{"$match": bson.M{"app_id": appId, "ir_add_date": irDate}},
bson.M{"$lookup": bson.M{"from": "tb_isr_visitors", "localField": "fb_uid", "foreignField": "fb_uid", "as": "res"}},
bson.M{"$unwind": "$res"},
bson.M{"$match": bson.M{"app_id": appId, "res.iv_add_date": ivDate, "ir_add_date": irDate}},
bson.M{"$group": bson.M{"_id": "$fb_uid"}},
bson.M{"$group": bson.M{"_id": 0, "counts": bson.M

{"$sum": 1}

}},
}

 

3. The command is normal , but mongo-go-driver demo is panic

Generated at Thu Feb 08 08:36:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.