2

We are trying to migrate Mongo 4.4 version to Document DB 3.6 - 4 version. While checking for compaitability we saw '$expr' operator not supported. Is there any alternative to this in AWS Documentdb?

Two sample statement :

RARELD.quoteLineItems.find({'$expr': {'$ne': ['$opportunityID', '$opportunityID']}}, {})  // ['$expr']
RARE2D.rareQuotes.aggregate([{'$match': {'lob': 'Medical', 'errors.errorList': {'$exists': True}, '$expr': {'$gte': [{'$size': '$errors.errorList'}, 3]}}}, {'$skip': 0}, {'$group': {'_id': 1, 'n': {'$sum': 1}}}])  // ['$expr']

1 Answer 1

0

There is no alternative to $expr as this is the only operator that allow's you to use aggregation operators within the query language, specifically when it comes to the simple queries (aka find).

When you're using an aggregation you can always find a workaround, it just might be less efficient.

Specifically with your aggregation example you can just write

'$expr': {'$gte': [{'$size': '$errors.errorList'}, 3]}}

as

"errors.errorList.2": {"$exists": True}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for editing my question. I will try to format the question properly next time. Thanks for you quick suggestion, I will look to code around this as suggested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.