Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-3966

$subtract is not supported in Aggregation Builder

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.20.0
    • Affects Version/s: None
    • Component/s: Compass
    • Labels:
      None
    • Iteration Ragamuffin

      Hi Team,

      I was trying to build a aggregation pipeline in Compass and getting error:

      Error Code:

      Expected "[" or AggregationStage but "{" found.
      

      Pipeline that I was trying to build in match stage:

       
      {$expr:{$gt:["$stars",{$subtract:["$postal_code", 14400000]}]}}
      

      Compass version that I am using: Version 1.19.12 (1.19.12)

      In mongo shell it's woking fine, however in Compass I am getting the same error.

      Command in mongo shell that I am executing:

      db.tips.aggregate([{$match:{$expr:{$gt:["$stars",{$subtract:["$postal_code", 14400000]}]}}}])
      

      However, If I remove the subtract from the pipeline it works fine.

      {$expr:{$gt:["$stars","$likes"]}}
      

      I got same error in Atlas Data explorer as well. After discussing this issue in Compass channel, I have opened this ticket.

        1. 1.19.png
          1.19.png
          51 kB
        2. 1.20.0-beta.9.png
          1.20.0-beta.9.png
          41 kB

            Assignee:
            maurizio.casimirri@mongodb.com Maurizio Casimirri
            Reporter:
            saurav.vaid@mongodb.com Saurav Vaid
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: