I am trying to filter documents using the following query:
db.projects.aggregate([
    {
        $project: { 
            deployments: { 
                $filter: { 
                    input: "$releases.deployments", 
                    as: "deployment", 
                    cond: { $eq: ["$$deployment.environment", "Live"] }
                }
            }
        }
    }
])
The output for deployments is always an empty array although if I change the condition to $ne then it returns all of the results.
How do I get the filter condition to return only records where deployment.environment equals the string Live?
Here is a sample piece of json:
{
      "project_id": "1",
      "project_group": "A",
      "releases": [
        {
          "version": "1",
          "deployments": [
            {
              "environment": "Integration",
              "created": "2019-10-01T06:40:01.000Z",
              "state": "Success",
              "name": "Deploy to Integration"
            },
            {
              "environment": "Test",
              "created": "2019-10-01T08:23:58.000Z",
              "state": "Success",
              "name": "Deploy to Test"
            },
            {
              "environment": "Live",
              "created": "2019-10-01T09:02:17.000Z",
              "state": "Success",
              "name": "Deploy to Live"
            }
          ]
        }
      ]
    }
 
     
    