Case Insensitive search with $in

后端 未结 6 1411
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 05:46

How to search a column in a collection in mongodb with $in which includes an array of elements for search and also caseInsensitive matching of thos

6条回答
  •  天命终不由人
    2020-12-15 06:34

    The way to do it in Java is:

    List nameList = Arrays.asList(name.split(PATTERN));
    List regexList = new ArrayList<>();
    for(String name: nameList) {
    regexList.add(Pattern.compile(name , Pattern.CASE_INSENSITIVE));
    }
    criteria.where("Reference_Path").in(regexList);
    

提交回复
热议问题