Spring Data Mongodb 3.0.3使用近查询进行计数的问题

问题描述

GeoJsonPoint point = new GeoJsonPoint(78.850300,35.732700);
Query query = new Query();      query.addCriteria(Criteria.where(FIELD_LOCATION_LONGLAT).near(point).mindistance(0.0).maxdistance(10000.0));
            
mongoTemplate.forTenant(mcsRequest.getCustomer()).find(query,DBTower.class,TOWERS_COLLECTION);

mongoTemplate.forTenant(mcsRequest.getCustomer()).count(query,TOWERS_COLLECTION);

查找成功,但计数得到此错误

org.springframework.data.mongodb.UncategorizedMongoDbException:命令失败,错误2(BadValue):服务器本地主机:27017上的“点必须仅包含数字元素”。完整的响应为{“ ok”:0.0,“ errmsg”:“点只能包含数字元素”,“ code”:2,“ codeName”:“ BadValue”};嵌套异常是com.mongodb.MongoCommandException:命令失败,错误2(BadValue):服务器本地主机:27017上的“点必须只包含数字元素”。完整的响应为{“ ok”:0.0,“ errmsg”:“点只能包含数字元素”,“ code”:2,2,“ codeName”:“ BadValue”}

我注意到CountQuery类将我的$ near查询变成了$ geoWithin,它以前没有这样做。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)