mongo聚合多条件查询

精确查询:is;
模糊查询:regex;
分页查询,每页多少:skip,limit
按某个字段排序(或升或降):new Sort(new Sort.Order(Sort.Direction.ASC, "port"))
查询数量:count
   

 Criteria criteria = new Criteria();//条件查询

criteria.andOperator(Criteria.where("distance").gte(distance - 20000),Criteria.where("distance").lte(distance + 20000));//条件查询,大于小于之间

    //query.addCriteria(criteria) ,query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "distance")))
Query query = new Query(criteria);
query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "distance")));//排序从小到大
List list = mongoTemplate.find(query,UserDO.class);

 

你可能感兴趣的:(mongo聚合多条件查询)