[JAVA-2715] Query builder for new lookup stage Created: 21/Dec/17  Updated: 28/Oct/23  Resolved: 03/Jan/18

Status: Closed
Project: Java Driver
Component/s: Builders
Affects Version/s: None
Fix Version/s: 3.7.0

Type: New Feature Priority: Major - P3
Reporter: Farès Hassak Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by JAVA-2712 Add support for new lookup with pipel... Closed

 Description   

Hello,

I want to implement a query builder for new lookup stage in 3.6.

{
   $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>
     }
}

Farès



 Comments   
Comment by Githook User [ 03/Jan/18 ]

Author:

{'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}

Message: JAVA-2715: Add to the reference documenation an example of Aggregates.lookup with variables and a nested pipeline
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/ebfa4ef34a8a2107ee537759a873660853a8638f

Comment by Githook User [ 03/Jan/18 ]

Author:

{'name': 'Farès Hassak', 'username': 'fhassak', 'email': 'fares.hassak@gmail.com'}

Message: JAVA-2715: Query builder for new lookup stage (#434)

JAVA-2715: Support lookup stage in Aggregates builder
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/5efa1339f5416b0f52b5edccf90ff093e5bdde6a

Comment by Farès Hassak [ 21/Dec/17 ]

yes, i understand.

https://github.com/mongodb/mongo-java-driver/pull/434

Comment by Jeffrey Yemin [ 21/Dec/17 ]

I'm aware of the Field class but it's inappropriate to re-use it. The semantics are different even if currently the properties are the same. They may need to evolve independently.

Comment by Farès Hassak [ 21/Dec/17 ]

I suggest using the Field class instead of a new variable class :

public class Field<TExpression> {
    private final String name;
    private TExpression value;
 
}

it looks like the Variable class will be identical to the Field class ?

Comment by Jeffrey Yemin [ 21/Dec/17 ]

That's great. Something like this?

        Aggregates.lookup("fromCollection", 
                          Arrays.asList(new Variable("x", xExpr), new Variable("y", yExpr)),
                          Aggregates.match(Filters.gt("age", 42)),
                          "outputField")

Generated at Thu Feb 08 08:57:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.