Database

[{"upVoted":{"count":2},"downVoted":{"count":3},"views":{"count":5},"creationDate":ISODate("2022-04-11T16:02:39.956Z"),"popularityIndex":1.453}]

Query

db.collection.aggregate([{$set:{popularityIndex:{$sum:[{$multiply:["$views.count",0.3]},{$multiply:["$upVoted.count",0.3]},{$multiply:["$downVoted.count",-0.2]},{$multiply:[{$dateDiff:{startDate:"$creationDate",endDate:"$$NOW",unit:"second"}},-0.2]}]}}}])

Result