Database

[{"_id":ObjectId("5e41877df4cebbeaebec5146"),"Paragraph":"My Name is John Smith.I am learning MongoDB database"},{"_id":ObjectId("5e4187d7f4cebbeaebec5147"),"Paragraph":"David Miller is a good student and learning Spring and Hibernate Framework."}]

Query

db.collection.aggregate([{$set:{Paragraph:{$reduce:{input:{$slice:[{$split:["$Paragraph"," "]},5]},initialValue:"",in:{$concat:["$$value",{$concat:["$$this"," "]}]}}}}},{$set:{Paragraph:{$substr:["$Paragraph",0,{$subtract:[{"$strLenCP":"$Paragraph"},1]}]},}}])

Result