All Products
Search
Document Center

:Does ApsaraDB for MongoDB support embedded/nested documents?

Last Updated:Jun 10, 2026

Yes. ApsaraDB for MongoDB supports embedded (nested) documents — a MongoDB feature that stores a related document as a field value inside a parent document, keeping related data in a single record without joins.

In the following example, fields is an embedded document containing a nested Status document with dest and orgi fields:

{
        "_id" : ObjectId("5cf0e51d8d1acb8a892ca65e"),
        "id" : "16399864",
        "timestamp" : "1453185620",
        "tablename" : "houseinfo",
        "dbname" : "corp_officebuilding",
        "primaryKeys" : "Id",
        "class" : "class com.uban.dts.bean.DtsLog",
        "dbType" : "MYSQL",
        "fieldCount" : "138",
        "opt" : "UPDATE",
        "fields" : {
                "Status" : {
                        "dest" : "0",
                        "orgi" : "1420041600"
                }
        }
}

To query a field inside an embedded document, use dot notation. For example, to match documents where fields.Status.dest equals "0":

db.collection.find( { "fields.Status.dest": "0" } )

Avoid querying on the full embedded document value (for example, { "fields.Status": { "dest": "0", "orgi": "1420041600" } }). This equality match requires an exact field order — if the field order changes, the query returns no results.