带排除字段的Spring数据mongoDB GeoNear查询

带排除字段的Spring数据mongoDB GeoNear查询,mongodb,geolocation,spring-data,Mongodb,Geolocation,Spring Data,我不知道我是否做错了什么,或者这是一个错误。 我有以下代码: Query criteria = new Query(Criteria.where("locationTime").gte( "date-time")); criteria.fields().exclude("friends"); NearQuery query = NearQuery.near(point).maxDistance(maxDistance) .

我不知道我是否做错了什么,或者这是一个错误。 我有以下代码:

    Query criteria = new Query(Criteria.where("locationTime").gte(
            "date-time"));
    criteria.fields().exclude("friends");

    NearQuery query = NearQuery.near(point).maxDistance(maxDistance)
            .num(limit).query(criteria);
    GeoResults<Profile> result = mongoTemplate
            .geoNear(query, Profile.class);
Query-criteria=新查询(criteria.where(“locationTime”).gte(
"日期及时间);;
criteria.fields().排除(“朋友”);
NearQuery query=NearQuery.near(点).maxDistance(maxDistance)
.num(限制).query(条件);
地理结果结果=mongoTemplate
.geoNear(查询、配置文件、类);
我正在执行查询,并根据距离和“locationTime”标准正确检索附近的配置文件,但它似乎忽略了排除字段,并与朋友一起检索配置文件。

当我使用简单查询时,排除/包括字段工作正常。
我到处找,找不到任何类似的用例,如果我做错了什么,请告诉我。


谢谢。

据我所知,使用
geoNear
命令无法限制字段


我试图调用
executeCommand
来绕过Spring数据的限制,但看起来他们甚至没有办法从原始命令中实现这一点。

我想在GeoNear查询中排除很多数据。。你是说它必须检索完整的文档吗?附近有工作吗?这样会非常慢。您可以尝试在常规查找语法中使用
$near
。它不能做
geoNear
所能做的一切,但如果你能将你的查询放入其中,你可以像通常使用find一样限制字段。谢谢你。。。你基本上是说mongo geo不支持排除字段的近距离查询吗?或者这是spring数据问题?这是mongo问题,而不是spring数据问题。另见。我找不到它的功能请求的票证——也许人们不使用geoNear处理大型文档。似乎是一个有效的功能。你知道我是否可以通过mongoTemplate(Spring数据)执行near查询吗?API似乎只提供geoNear方法。。