The case with parentheses in MongoDB fuzzy query

q.addCriteria(Criteria.where("mongod库对应field")
.regex(Pattern.compile(Pattern.quote(field对应的值), Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE)));

eg: the attribute fileName corresponding to the mongodb collection

Criteria criteria=new Criteria();

if(Stringutils.isNotBlank(req.getFileName())){
criteria.and("file_name").regex(Pattern.compile(Patter.quote(req.getFileName())))

}

Guess you like

Origin blog.51cto.com/1929297/2679388