带有排除字段的春季数据mongoDB GeoNear查询


我不知道

我做错了什么还是错误。我有以下代码:

    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);

我正在根据距离和"locationTime"标准正确检索附近的查询和配置文件,但它似乎忽略了排除的字段并与他们的朋友一起检索配置文件。

当我使用简单查询时,排除/包含字段可以完美地工作。
我到处看了看,找不到任何类似的用例,如果我做错了什么,请告诉我。

谢谢。

我所知,没有办法用geoNear命令限制字段。

我考虑过调用executeCommand来尝试解决 Spring Data 的限制,但看起来他们甚至没有办法从原始命令中做到这一点。

最新更新