Announcement Announcement Module
Collapse
No announcement yet.
Mongo DB: QueryDSL Support for $regex and $nin on same field Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Hi Bernd.

    Feel free to create a ticket for this on GitHub.

    Br,
    Timo

    Comment

    Working...
    X