question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for $lookup with `let`/`pipeline` form to aggregation [DATAMONGO-2467]

See original GitHub issue

Shiv 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:open
  • Created 4 years ago
  • Reactions:35
  • Comments:5

github_iconTop GitHub Comments

8reactions
spring-projects-issuescommented, Dec 30, 2020

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

0reactions
keyzjcommented, Nov 6, 2022

Any update on this issue?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found