-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Aggregation Framework
-
None
-
Fully Compatible
-
Query 2016-11-21
As Asya pointed out in a comment on SERVER-23313:
I don't think this error message is always correct/helpful:
"errmsg" : " 'newRoot' argument to $replaceRoot stage must evaluate to a valid Value, try ensuring that your field path(s) exist by prepending a $match: {<path>: $exists} aggregation stage.",If the field (say "$a") is not an object we correctly say
try ensuring that it evaluates to an object by prepending a $match: {<path>: {$type: 'object'}}Is there a reason not to always say that even if the field is missing? Also if path is missing or there but null they don't need to match, they might need to $ifNull inside newRoot, maybe to preserve document counts or fill in some default values.
Also they might correct such errors via checking $type of path (in addition or instead of $ifNull) to fill in default values...
We should take some time to ensure these error messages are clear and helpful, without proposing a solution that might not always be ideal.
- is related to
-
SERVER-23313 Add a $replaceRoot stage which allows promoting a sub-document to the top level
- Closed