Results 1 to 2 of 2

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

  1. #1

    Default 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?
    Best regards.

  2. #2
    Join Date
    Jan 2006
    Location
    Edmonton, Alberta, Canada
    Posts
    63

    Default

    "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.
    Yuan Ji
    www.jiwhiz.com - Passion for beautiful design

Tags for this Thread

Posting Permissions

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