-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
None
-
None
-
None
-
None
-
None
-
None
-
None
Currently on a sharded collection on field of $merge if not present, defaults to _id + shard key:
https://www.mongodb.com/docs/manual/reference/operator/aggregation/merge/#std-label-merge-on
However, if we explicitly state _id + shard key on a collection that doesn't have _id as a part of it's shard key, $merge validation will fail, because it won't find an index that is unique and matches all on fields.
It would be nice to make the default value of "on" behave consistently if it is explicit or not.
Small repro script attached: repro.js![]()
Note that in EXPLAIN DEFAULT "on" field is serialized to .[_id, shardKey]