Support comparison expressions against arrays in $lookup

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Query Execution
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Consider the following pipeline: 

      [{$lookup: {
        from: "foreign",
        let: {maxValue: "$maxValue"},
        pipeline: [{$match: {
          $expr: {$lte: ["$values", "$$maxValue"]}
        }}],
        as: "output"
      }}]

      Because of $lookup, we are forced to use $expr to be able to reference maxValue, which is dependent on current document.

      However, it will use $lte from aggregation expressions, not from match expressions.

      This is important if we want an array lookup (e.g. match all documents where values array contains at least one element less than or equal to $$maxValue).

      Even if we implement correct semantics via $filter, we won't be able to use multi-key index on values.

       

              Assignee:
              Unassigned
              Reporter:
              Ivan Fefer
              Votes:
              2 Vote for this issue
              Watchers:
              10 Start watching this issue

                Created:
                Updated: