Mongodb的常用语句
模糊查询 regex(".*?\\"+questionContent+".*")
String questionContent = "需求"; Query query = new Query(); query.addCriteria(Criteria.where("demandName").regex(".*?\\"+questionContent+".*")); System.out.println(mongo.count(query, AdvTrusteeship.class));
// 解决模糊查询 数字查不出结果【最终版】
Pattern pattern = Pattern.compile("^.*" + situation.getTitle() + ".*$", Pattern.CASE_INSENSITIVE);
query.addCriteria(Criteria.where("title").regex(pattern));