Mongodb – What “fromRouter” option means on MongoDB aggregations

mongodb

Recently i notice that a parameter fromRouter" : true exists on mongoDB aggregations. I search the MongoDB documentation and google for it, but i didn't found anything about it. Can anyone explain what this parameter is, or share any useful resource for it?

"op" : "command",
"ns" : "database_name.$cmd",
"command" : {
    "aggregate" : "collection",
    "pipeline" : [...erase them to make the post smaller...],
    "fromRouter" : true,
    "$queryOptions" : {
        "$readPreference" : {
            "mode" : "primary"
        }
    }
},
"ntoreturn" : 1,
"keyUpdates" : 0,
"numYield" : 440,
"lockStats" : {
    "timeLockedMicros" : {
        "r" : NumberLong(3106252),
        "w" : NumberLong(0)
    },
    "timeAcquiringMicros" : {
        "r" : NumberLong(5302577),
        "w" : NumberLong(6145)
    }
},

Best Answer

It just means that this is a sharded cluster and the aggregation is happening via a mongos (also known as a query router). This is important for aggregations internally because it means that the output from multiple shards may need to be merged but it's not really relevant for most end users (you usually already know you are running in a sharded environment).