Announcement Announcement Module
Collapse
No announcement yet.
How describe MongoDb regex 'IgnoreCase' query using interface method name? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How describe MongoDb regex 'IgnoreCase' query using interface method name?

    Hi guys.

    Can you suggest how make Regex query using Interface with 'IgnoreCase' ?

    I have working code:
    Code:
    Query query = Query.query(Criteria.where("fieldName").regex(fieldValue, "i"));
    but code like
    Code:
    public List<SomeType> findByFieldNameRegexIgnoreCase(String fielValue);
    
    - Created query Query: { "fieldName" : { "$regex" : "rolley"}}, Fields: null, Sort: null
    doesn't work as I understand. I don't get correct result as with : Criteria.where("fieldName").regex(....
    Should I do 'custom implementation' in such case?

  • #2
    "IgnoreCase" keyword was introduced to Spring Data Common since 1.2 M1 (See DATACMNS-66. But I tried a test with repository, seems findByFieldNameRegexIgnoreCase doesn't work with Spring Data MongoDB 1.1.0.RELEASE. Same result like you had.

    To work around, you can add another field called "fieldName2" to your document object, storing all lower case of "fieldName", and use findByFieldName2Regex(String fieldValue2), and lower case fieldValue2 before call this method.

    Comment


    • #3
      You can use findByFieldNameIgnoreCase(String fieldValue), but it still doesnt work with spring-data-mongodb 1.3.1

      I open a jira ticket about these very basic bug https://jira.springsource.org/browse/DATAMONGO-770

      Use QueryDSL and its working pretty well ) see my jira ticket

      Comment

      Working...
      X