MongoDB.live, free & fully virtual. Register Now MongoDB.live, free & fully virtual. Register Now

I am Getting an error while running my query kindly suggest the change

[thread1] Assertion: 10334:BSONObj size: 17114398 (0x105251E) is invalid. Size must be between 0 and 16793600(16MB) First element: 0: { _id: “0714015625”, max: { _id: ObjectId(‘5f55945299a36c0a0d18f386’), EventDTM: “2020-09-07T02:00:10.592”, EventTypCD: “03”, DelNo: “0714015625”, Cust_Ship_To_ID: “0012607572”, Cust_Ship_To_Address: “T.SALA DAENG, A.MUANG 3/3 M.2 14000 ANG THONG Lopburi TH”, SoldToID: “0012607572”, Delivery_Event_Message_Text: “2 hours before delivery”, Planned_Delivery_DateTime: “2020-09-07T04:00:00.000”, Purchase_Order_Number: “”, Sales_Order_Number: “0249278737”, Source_Application_ID: “1”, Time_To_Delivery_Period: “02:00”, DELIVERY_ITEM: [ { Product_Code: “550047529”, Product_Name: “RimR3Turbo20W50CH4_1*209L_A227”, Shipment_Quantity: “1”, Unit_Of_Measure_Code: “EA” } ] } } src/mongo/bson/bsonobj.cpp 101
2020-09-07T10:43:13.471+0000 E - [thread1] Assertion: 10334:BSONObj size: 17114476 (0x105256C) is invalid. Size must be between 0 and 16793600(16MB) src/mongo/bson/bsonobj.cpp 101
2020-09-07T10:43:13.471+0000 E - [thread1] Assertion: 10334:BSONObj size: 17114501 (0x1052585) is invalid. Size must be between 0 and 16793600(16MB) src/mongo/bson/bsonobj.cpp 101
2020-09-07T10:43:13.472+0000 E QUERY [thread1] Error: BSONObj size: 17114501 (0x1052585) is invalid. Size must be between 0 and 16793600(16MB) :

My Query is:

query = [
   
	{'$match': {'EventTypCD': {'$ne': '04'}}},
	
    {
        $group: { 
            '_id':"$DelNo",
            'max':{'$first':"$$ROOT"}
        }
    },
   {
        '$sort': {
            'EventDTM': -1
        }
    }
]

db.DELIVERY_EVENT.aggregate(query).pretty()

Kindly help!!!

Hello @Neha_Sinha welcome to community!

The maximum BSON document size is 16 megabytes, you seem to exceed this limit.

In a first step I’d suggest to review your document schema, do you really need to have such a huge document? Or do you try to store files in the collection, in that case gridFS is your friend.

This is a starting point to help you to solve your issue. In case you get stuck, feel free to provide further details, we will try to help.

Cheers,
Michael

1 Like