Search code examples
javacouchbasecouchbase-java-api

Couchbase - find document by regexp using uppercase words


Using couchbase 5.1.1 and java client 2.6.1.

On database, I have bucket with name config and have one document:

[
 {
    "section": "MAIL",
    "id": "aaa.1.0.0.MAIL",
    "version": "1.0.0",
    "values": {
        "mail" : "test1@test1.com"
    }
 }
]

Now, I want to find doucment using regular expresion on fields:

bucket.query(new SearchQuery("configindex", SearchQuery.regexp(regexp).field("sectrion"));

If I put word using lowercase e.g.: mail, everything is fine and I recive document, but if I put word using uppercase like MAIL, what is exactly matches with fields value, I have no answear. Can You explain me, why I can't search using uppercase words?

EDIT:

If I put MA.* for regexp - it's not workig, ma.* - was working. I only want to know, why I can't use uppercase on regural expression when I have field value "section" : "MAIL". Why it's not working? but if I put "mail", it means lowercase on regexp, everythink was fine...


Solution

  • As a guess, in case you're using a regex like: "[a-z]" it will only work with lowercase characters.

    Assuming that your regex is "[a-z]" try changing it by "[A-Za-z]" which will work for uppercase and lowercase. Something like:

    bucket.query(new SearchQuery("configindex", SearchQuery.regexp("[A-Za-z]").field("section"));