问 题 在使用spring-data-mongo做统计时,需要比较两个字段是否相等,比如 l==qzt 就像find中查询 db.dbName.find({$where:"this.l=this.qzt"}) 这段代码是能查询出来的 但是在使用spring-data-mongo Aggregation的时候 就报以下错误 "errmsg" : "$where is not allowed inside of a $match aggregation expression" , "code" : 16395 我是这样用的: Criteria c = Criteria.where("$where").is("this.qzt==this.l"); Aggregation agg =Aggregation.newAggregation( Aggregation.match(c), Aggregation.group("qzc").count().
以下是关于 spring-data-mongo 的编程技术问答
问 题 1.最近在使用spring-boot和用spring-data-mongo操作mongodb 2.每天早上查看服务器日志都发现报了同一个错,估计是在一整晚没人访问服务器,第二天一旦有人访问就会发生错误 3.错误日志为: 07:51:35.185 [cluster-ClusterId{value='59295e6c3532f223626a2ca0', description='null'}-localhost:27017] INFO org.mongodb.driver.cluster - Exception in monitor thread while connecting to server localhost:27017 com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message at com.mongodb.connection.Interna
问 题 0 gradle dependencies { compile("org.springframework.boot:spring-boot-starter-data-mongodb") } 1 . 实体类。省略 get set public class Customer { @Id private String id; private String firstName; private String lastName; 2 . repository public interface CustomerRepository extends MongoRepository { public Customer findByFirstName(String firstName); public List findByLastName(Strin
问 题 请问有类似的案例吗 ? xml配置方式就不要了 。 解决方案 先写两个MongoTemplate: @Bean(autowire = Autowire.BY_NAME, name = "firstMongoTemplate") public MongoTemplate firstMongoTemplate() throws Exception { return new MongoTemplate(new MongoClient("1.1.1.1", 27017,database); } @Bean(autowire = Autowire.BY_NAME, name = "secondMongoTemplate") public MongoTemplate secondMongoTemplate() throws Exception { return new MongoTemplate(new MongoClient("2.2.2.2",
问 题 先把案例奉上,让大家先理解我的意思: https://segmentfault.com/a/1190000004157112 上面这个链接是一个普通的sqlgroup查询,但是我现在碰到的问题是用mongo进行group查询 聚合查询实在是要了老命了,下面是模拟数据: (请原谅我的数据,他放荡不羁爱zhi由) { "_id" : ObjectId("590c15751f70bd329f8a972d"), "_class" : "com.birdnest.model.AppPublish", "user" : "admin", "deviceType" : "nurse", "version" : "1.1。2。2", "message" : "范德萨312313213213范德萨", "creation" : ISODate("2017-05-05T06:02:29.300Z") } {