mongoTemplat模糊查询


1.模糊查询

//完全匹配
Pattern pattern = Pattern.compile("^羊$", Pattern.CASE_INSENSITIVE);
//右匹配
Pattern pattern = Pattern.compile("^.*羊$", Pattern.CASE_INSENSITIVE);
//左匹配
Pattern pattern = Pattern.compile("^羊.*$", Pattern.CASE_INSENSITIVE);
//模糊匹配
Pattern pattern = Pattern.compile("^.*羊.*$", Pattern.CASE_INSENSITIVE);
Query query = Query.query(Criteria.where(keyWord).regex(pattern));  
        List<SimpleUserInfo> users = mongoTemplate.find(query, SimpleUserInfo.class, classname);
        return users;



阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页