Questions tagged [mongodb-lookup]
41 questions
1
vote
2 answers
Mongodb lookup with match in aggregate returns an empty array
This is my user document
{
"_id":"02a33b9a-284c-4869-885e-d46981fdd679",
"context":{
"email":"someemail@gmail.com",
"firstName":"John",
"lastName":"Smith",
"company":[
"e2467c93-114b-4613-a842-f311a8c537b3"
…

Ognjen Kljajic
- 37
- 5
1
vote
2 answers
MongoDB aggregation with nested arrays of objects
I'm striving to get some aggregated data from Mongo DB. I have the following collections:
Restaurants:
{
"_id" : ObjectId("5e0ff6d424f9fc12bc3d9464"),
"name" : "Pizzaria Don Juan",
"active" : true,
"users" : [
…

erickles
- 157
- 2
- 16
1
vote
1 answer
$match value of local field (nested field) not empty string in $lookup pipeline
I cant use a nested field on an lookup pipeline expression, to get only the not empty string values.
I am doing an aggregate query with 2 lookup stages, where the second lookup query depends on a nested field of the result of the first lookup. I…

Bujar Deari
- 23
- 3
1
vote
1 answer
$lookup with two $concat fields
Given those documents:
{
"name" : "User",
"class" : "clazz",
"reference" : "ref"
}
{
"classReference" : "clazz+ref",
"room" : "123"
}
How can I do a $lookup to retrieve a document like this (without changing the documents):
{
…

Felipe
- 143
- 1
- 15
1
vote
1 answer
How to use ObjectId in $lookup using mongodb nodejs drivers
Please help me to find out a suitable solution
collection were users details are stored app_users
{
_id: {
$oid: "abcd1235a6ad4a56dadasd"
},
user_name: "vikas Kandari",
user_dp: "ASDAD486412.jpg"
}
collection where users bookings are…

Vikas Kandari
- 793
- 6
- 10
0
votes
0 answers
VBA Dlookup work with embedded table, but not with linked tables
I'm working with a very simple table:
VendorID Primary Key
VendorType Short Text
VendorName Short Text
VendorNumber Short Text
I have a very simple line of vba code:
dlookup("VendorName","aSuppliers","VendorID = " & 8)
It works perfectly.…
0
votes
1 answer
Auto conversion of foreign key from string to ObjectId to make $lookup aggregation work by MongoDB
I have two collections and I am using one of collections _id field as foreign key in other collection. But _id is Object and in in other collection it is string so $lookup is not able to match.
Collection 1: User collection
{ "_id" :…

Alok
- 7,734
- 8
- 55
- 100
0
votes
1 answer
How to improve the performance of Aggregation Pipeline in MongoDb C#
I have a MongoDB aggregation pipeline, which I have written in C#.
$geoNear{
near: {
type: "Point",
coordinates: [-110.29665, 31.535699],
},
distanceField: "distance",
maxDistance: 100,
query: {
$and: [
{
…

Shehan V
- 164
- 1
- 14
0
votes
0 answers
Inside a pipeline, perform a search in other collection without $lookup MongoDb
Inside my existing pipeline, I wanna get a sample of 10 documents from another collection (another collection different than the one that the pipeline is targeted at).
I could do this with $lookup, but it would perform this search in other…

Pedro Rabbi
- 193
- 1
- 12
0
votes
1 answer
Having issues matching local and foreign fields in a $lookup pipeline for a MongoDB aggregate query
I have a two different collections, one for emailtemplates, and one for emails. And what I'm trying to do is write an aggregate pipeline that will show how many times each template has been sent using the templates name from the emailtemplates…

J H
- 3
- 2
0
votes
1 answer
does $lookup use indexes in the foreignField key?
In the example below, if the collection inventory has an index on the sku field, will it be used in this $lookup operation?
db.orders.insertMany( [
{ "_id" : 1, "item" : "almonds", "price" : 12, "quantity" : 2 },
{ "_id" : 2, "item" :…

Bear Bile Farming is Torture
- 4,317
- 4
- 27
- 61
0
votes
1 answer
How to add condition in mongodb aggregate lookup?
I have two collections university and college.
Under one university multiple colleges are there. I want to get the university and college detail according to below condition:
1.First get the university which have maximum no of colleges under…

Sensei_75
- 56
- 4
0
votes
1 answer
$lookup with pipeline match and projection does not work for guid
I have two collections that I want to join with $lookup based on two id fields. Both fields are from type guid and looke like this in mongodb compass: 'Binary('cavTZa/U2kqfHtf08sI+Fg==', 3)'
This syntax in the compass aggregation pipeline builder…

M. Altmann
- 726
- 5
- 20
0
votes
1 answer
Get matched and unmatched count from another collection mongodb
I have two collection present in mongodb database. one status column is common. I need matched and unmatched count from both the collection based on status column.
I have written some code but it fetching only matched…

Coder
- 184
- 15
0
votes
1 answer
Mongodb lookup for not equal fields
I want to join two collections and find the documents where has one equal field and one unequal field!
This is what I was tried, But not work
db.collectionOne.aggregate[
{
"$match": {
"$and": [
{ "$text": {…

aidinMC
- 1,415
- 3
- 18
- 35