Expected Behaviour
Using the aggregation pipeline I can perform the following:
- project an entire document using the $$ROOT variable
- perform some filtering
- then using ReplaceRoot return the same structure
Example below:
db.test.aggregate( [ { $project: { "doc": '$$ROOT', "dif":{"$setDifference":["$X",["tag1","tag2"]]},"_id":0 } }, { $match: { "dif":{"$size":0} } }, { $replaceRoot: { newRoot: '$doc' } }, ] );
Using Linq, I believe this would be represented using the following Linq query:
collection.AsQueryable()
.Select(c => new { doc = c, dif = c.X.Except(tags), Id = c.Id })
.Where(c => c.dif.Count() == 0)
.Select(c => c);
Actual Behaviour
Returns the following error when executed:
$project or $group does not support {document}.
Stack trace:
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateValue(Expression node)
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateMapping(ProjectionMapping mapping)
at MongoDB.Driver.Linq.Translators.AggregateLanguageTranslator.TranslateValue(Expression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateProjectValue(Expression selector)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateSelect(SelectExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslateWhere(WhereExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.TranslatePipeline(PipelineExpression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node)
at MongoDB.Driver.Linq.Translators.QueryableTranslator.Translate(Expression node, IBsonSerializerRegistry serializerRegistry, ExpressionTranslationOptions translationOptions)
at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Translate(Expression expression)
at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression)
at MongoDB.Driver.Linq.MongoQueryableImpl`2.GetEnumerator()
at MongoDB.Driver.Linq.MongoQueryableImpl`2.System.Collections.IEnumerable.GetEnumerator()
- is duplicated by
-
CSHARP-2104 $project or $group does not support <document>
- Closed
- is related to
-
CSHARP-1772 Quering for first item of GroupBy aggregation produces NotSupportedException
- Closed
-
CSHARP-2104 $project or $group does not support <document>
- Closed