Getting issue Upgrading from Mongo driver version 3.8.1 to 4.6.1

88 views Asked by At

After updating the mongo driver version from 3.8.1 to 4.6.1. I am getting below error in my existing queries

"Unrecognized pipeline stage name: '$and'"

All the aggregations were working Earlier. Spring boot version - 2.7.10 Java version - 11

If I revert the version from 4.6.1 to 3.8.1, I get class not defined error. Pls help me in resolving this issue

1

There are 1 answers

0
HMT On BEST ANSWER

The issue was with the Match Pipeline , it was adding and two times but it was working fine in previous version biut breaking when we were using the new verison. I modified the below code : Instead of this

pipeline.add(and

Use this:

pipeline.addAll