paolov Posted November 30, 2017 Share Posted November 30, 2017 Hi,i'm trying to use a mongo db query with a $regex operator as condition for one of the field but while the same query used directly on a mongo db client works correctly, it does show any result in jasper.here and extract of the query i'm using:{ 'collectionName' : 'myColl', findQuery :{ MOV : 'SCO-DDT', "CODE":{"$regex" : '^(?!GEN)(?!LOC)w*$'}, CODSTO : {"$in" : $P{Store}}, CODAGGRSECT_RPT03 : {"$in":$P{AggrSector}}, LIBNOLIB : "LIB", DATE : {'$gte' : $P{Date_From}, $lte : $P{Date_To}} }}As said, the same query executed directly from the mongo db shell works perfectly.i've also tried using $not instead of $regex{ 'collectionName' : 'myColl', findQuery :{ MOV : 'SCO-DDT', "CODE":{"$not" : '(^GEN|^LOC)w*$'}, CODSTO : {"$in" : $P{Store}}, CODAGGRSECT_RPT03 : {"$in":$P{AggrSector}}, LIBNOLIB : "LIB", DATE : {'$gte' : $P{Date_From}, $lte : $P{Date_To}} }}but in this case Jasper return a mongo db error: "$not needs a regex or a document"anyone else have these problems with $regex and $not?thanks Link to comment Share on other sites More sharing options...
sthomas_3 Posted March 1, 2018 Share Posted March 1, 2018 You may try as below: {collectionName:'myColl',findQuery:{'code':{'$regex' : '^((?!GEN)(?!LOC).)*$'}}} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now