1

I am trying to apply $setWindowFields aggregation in mongodb compass. But it is not working. I am following this tutorial. I am trying to convert below code to mongodb compass aggregation document.

[{
    $setWindowFields: {
        partitionBy: "$source",
        sortBy: { ts: 1 },
        output: {
            "window.rollingCloseUSD": {
                $avg: "$closeUSD",
                window: {
                    documents: [-5, 0]
                }
            }
        }
    }
},
{
    $merge: {
        into: "stock_exchange_data_processed",
        whenMatched: "replace"
    }
}]

0 Answers0