Add support for $lookup with `let`/`pipeline` form to aggregation [DATAMONGO-2467]
See original GitHub issueShiv Jha-Mathur opened DATAMONGO-2467 and commented
Perform uncorrelated subqueries between two collections as well as allow other join conditions besides a single equality match:
{
$lookup:
{
from: <collection to join>,
let: { <var_1>: <expression>, …, <var_n>: <expression> },
pipeline: [ <pipeline to execute on the collection to join> ],
as: <output array field>
}
}
Reference URL: https://docs.mongodb.com/master/reference/operator/aggregation/lookup/#join-conditions-and-uncorrelated-sub-queries
1 votes, 2 watchers
Issue Analytics
- State:
- Created 4 years ago
- Reactions:35
- Comments:5
Top Results From Across the Web
$lookup (aggregation) — MongoDB Manual
Performs a left outer join to a collection in the same database to filter in documents from the "joined" collection for processing. The...
Read more >Spring Data MongoDB Lookup with Pipeline Aggregation
First, I had to create a custom aggregation operation class so that I could pass in a custom JSON mongodb query to be...
Read more >MongoDB Lookup Aggregations: Syntax, Usage & Practical ...
Specifies the name of the new array field to add to the joined documents. The new array field contains the matching documents from...
Read more >Adding Lookup Data to the Aggregation Pipeline | Studio 3T
When you run a stage based on the $lookup operator, MongoDB adds an array field to each document in the primary collection. The...
Read more >How to Use the $lookup Function in MongoDB | ObjectRocket
When you're querying data in MongoDB, there are times when you need information that's stored in documents across multiple collections.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Herman Bovens commented
I think this one deserves Major priority instead of Minor. Uncorellated subqueries and multiple join conditions are just two possible uses, but there is more. Not being able to use a pipeline for lookup leads to inefficient queries: instead of doing a $project operation inside the $lookup operation when not all fields of the target document are needed, people fall back to doing the projection after the lookup (or even not at all). Limiting the number of fields has proven to be faster for me, definitely much faster if the index on the target collection that is used contains all of the projected fields
Any update on this issue?