Database

[{id:1,text:"Some text",paragraph:1},{id:2,text:"This has field paragraph 2",paragraph:2},{id:3,text:"This also has paragraph 2 field",paragraph:2},{id:4,text:"Some other text",paragraph:3},]

Query

db.collection.aggregate([{$group:{_id:"$paragraph",texts:{"$push":"$text"}}},{$project:{_id:0,id:"$_id",paragraph:"$_id",text:{$trim:{input:{$reduce:{"input":"$texts","initialValue":"","in":{$concat:["$$value"," ","$$this"]}}}}}}},{$sort:{id:1}}])

Result