Results 1 to 2 of 2

Thread: Mongo DB: QueryDSL Support for $regex and $nin on same field

  1. #1
    Join Date
    Aug 2012
    Location
    Germany
    Posts
    1

    Default Mongo DB: QueryDSL Support for $regex and $nin on same field

    I need QueryDSL Support for $regex and $nin on same field.
    It seams to step in the trap that is mentioned in the mongoDb advanced Query hint:

    "If you wish to specify both a regex and another operator for the same field, you need to use the $regex clause. For example, to find the customers where name matches the above regex but does not include 'acmeblahcorp', you would do the following:

    Code:
    db.customers.find( { name : { $regex : /acme.*corp/i, $nin : ['acmeblahcorp'] } } );"
    I've tried something like:
    Code:
    List names = ....;
    QCustomers.customers.name.startsWith('Mi').and.notIn(names)
    querydsl version: 2.3.3
    Spring Data version: 1.0.3.RELEASE

    A workaround using JSON Query is 2nd best, because i would like to use only querydsl. If you suggest using JSON query, how to code a regex like name : /^acme/ ? Simple copy the example above doesn't deliver the expected results.

    Thanks

    Bernd

  2. #2
    Join Date
    Aug 2011
    Posts
    8

    Default

    Hi Bernd.

    Feel free to create a ticket for this on GitHub.

    Br,
    Timo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •