How to query mongodb with “like” using the java api?

前端 未结 7 1930
谎友^
谎友^ 2020-12-14 00:59

this question is very similar to another post

I basically want to use the mongodb version of the sql \"like\" \'%m%\' operator

but in my situation i\'m using

7条回答
  •  轮回少年
    2020-12-14 01:19

    To make it case insensitive:

    Document doc = new Document("name", Pattern.compile(keyword, Pattern.CASE_INSENSITIVE));
    collection.find(doc);
    

提交回复
热议问题