Jump to content
JasperReports Library 7.0 is now available ×

Mongo DB query with $regex (or $not) does not work


paolov

Recommended Posts

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

  • 3 months later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...