[SERVER-27517] $lookup into a pipeline Created: 27/Dec/16  Updated: 06/Dec/22  Resolved: 27/Nov/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: 3.2.8, 3.4.0
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: tisha Kariya Assignee: Backlog - Query Team (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-29072 Add support for $lookup into a sub-pi... Closed
is duplicated by SERVER-27372 Add Comparison Operators in $lookup Closed
Related
Assigned Teams:
Query
Participants:

 Description   

I have been trying to limit lookup, i.e. limit lookup to check only first 1000 documents from joined collection, it fails.
Also i do not want to use $out separately as i am using it to create a report which needs one line query.
Is there any way i can do it??



 Comments   
Comment by tisha Kariya [ 08/May/19 ]

Thanks James

Comment by James Wahlin [ 27/Nov/17 ]

Hi tishakariya@gmail.com,

$lookup into a sub-pipeline has been implemented and will be available in our upcoming MongoDB 3.6 release. It is currently available for testing as part of our 3.6 release candidates.

Given this, we will close this ticket as a duplicate of SERVER-29072 which delivered this feature.

As for your additional question:

Also i do not want to use $out separately as i am using it to create a report which needs one line query.
Is there any way i can do it??

If you still have a question related to $out, please open a new ticket and provide a detailed example of what you are looking to accomplish.

Thanks,
James

Comment by David Storch [ 27/Dec/16 ]

Hi tishakariya@gmail.com,

This is being sent to the Query Team for triage.

As my colleague kyle.suarez mentioned, you can accomplish this using read-only non-materialized views starting in MongoDB 3.4. However, adding the ability to explicitly lookup into a pipeline is an interesting feature request in its own right. Please continue to watch this ticket for updates.

Best,
Dave

Comment by Kyle Suarez [ 27/Dec/16 ]

In MongoDB 3.4+, you can create a view on the collection to look up from and apply a limit:

db.createView("view", "collectionToLookUpFrom", [ { $limit: 1000 } ]);
db.collection.aggregate( [ { $lookup: { from: "view", ... } } ] );

Not sure about earlier versions, though.

Generated at Thu Feb 08 04:15:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.