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));

 

posted @ 2019-09-06 16:48  低调人生  阅读(424)  评论(0编辑  收藏  举报