44 questions
1 vote
0 answers
26 views
Efficient Pagination with $lookup across Two MongoDB Collections with Filters on Both Sides
I have two MongoDB collections: c1 and c2. c1 has properties: p1, p2 c2 has properties: p3, p4 c1._id is referenced by c2.customerId I need to: Perform a $lookup to join c1 with c2 Apply filters on ...
0 votes
0 answers
38 views
Index not getting applied while $lookup for one of my query but for others it's getting applied. Not able to find out the mistake i am doing
Index not getting applied while $lookup (Customers lookup in my query, _id index is not getting applied) for one of my query but for other query it’s getting applied. Below is the plan details which ...
0 votes
1 answer
119 views
MongoDB query of filter data based on field present in foreign collection after the lookup is taking time
I have 2 collections Customers and Orders. I have to filter the customers who have placed the order in the last 60 days. The aggregation that I have written to get this data is taking a lot much time. ...
0 votes
1 answer
47 views
create view aggregating 3 collections with a concatenation
I have 3 collections. I would like to create a view that would tell me if the image file of the image collection is used on another collection. Images "_id": "...
0 votes
1 answer
540 views
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. ...
0 votes
1 answer
112 views
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",...
1 vote
0 answers
69 views
MongoDb $Lookup doesn't work as expected in C#
I have a C# method that returns users' property data in a particular area using $geoNear and $project. I used the below pipeline to get the result. var pipeline = new[] { ...
0 votes
0 answers
100 views
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, ...
0 votes
1 answer
1k views
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 ...
0 votes
1 answer
940 views
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" : "...
0 votes
1 answer
525 views
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 ...
0 votes
1 answer
1k views
$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 ...
1 vote
1 answer
34 views
How to get associated document who satisfy match object
In the following query, I want to fetch all verified students and their related meetings. but Trying to fetch all upcoming meetings which means meetings having at least one future date time. My ...
0 votes
1 answer
409 views
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 ...
0 votes
1 answer
3k views
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&...