【发布时间】:2016-04-19 09:15:09
【问题描述】:
这是我的代码
Criteria c = new Criteria();
c.andOperator(Criteria.where("country").is(country),
Criteria.where("createTime").lte(wp),
Criteria.where("location").withinSphere(circle),
Criteria.where("titleContent").exists(true));
AggregationOperation match = Aggregation.match(c);
AggregationOperation limit = Aggregation.limit(20);
AggregationOperation sort = Aggregation.sort(new Sort(Sort.Direction.DESC, "createTime"));
AggregationOperation group = Aggregation.group("titleContent").sum("count").as("titleCount").count().as("contentCount");
Aggregation aggregation = Aggregation.newAggregation(match, sort, limit, group);
AggregationResults<TitleRes> result = template.aggregate(aggregation, "post", TitleRes.class);
当我添加Criteria.where("location").withinSphere(circle)
会抛出异常
org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class org.springframework.data.mongodb.core.query.GeoCommand
当我删除Criteria.where("location").withinSphere(circle)
没关系。
我不知道如何处理它。我想在Sphere中获取数据。
【问题讨论】:
标签: java mongodb spring-boot