Announcement Announcement Module
Collapse
No announcement yet.
mongoDB - Query using regex with options Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • mongoDB - Query using regex with options

    Hi all,
    i'm kind of embarrassing, i'm trying to write a query using regex with options with Spring data mongdb 1.0.0.M2
    Using regex is ok but i cannot find a way to add options to get something like :
    Code:
    db.customers.find( { name : { $regex : 'acme.*corp', $options: 'i' } } );
    i want to turn it case insensitive.
    i guessed i just had to do something like :
    Code:
    Criteria.where("name").regex("'acme.*corp").options("i")
    but method "options" does not exist
    Anyone knows a way to do it correctly ?
    Thx !

  • #2
    Could you try with a more recent version of the Spring Data MongoDB support like 1.0.0.M4. I know we added the options as a second parameter to the regex() method at some point.

    Code:
    Criteria r = Criteria.where("name").regex("'acme.*corp'", "i");

    Comment


    • #3
      Indeed, it works fine with Spring Data Mongo 1.0.0.M4
      i had minor changes to do with mongo's config (differences between 1.0.0.M2 and 1.0.0.M4), but now everything's fine !

      I thank you !

      Comment

      Working...
      X