弹簧数据mongoDB几何查询与排除字段 [英] Spring data mongoDB GeoNear query with excluding fields

查看:286
本文介绍了弹簧数据mongoDB几何查询与排除字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道自己做错了什么,或者是错误。
我有以下代码:

pre $ 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<个人资料> result = mongoTemplate
.geoNear(query,Profile.class);

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



当我使用简单的查询时,exclude / include字段完美地工作。 >
我查看了每个地方,找不到任何类似的用例,请告诉我,如果我做错了什么。



谢谢。

解决方案

无法通过 geoNear 命令来限制字段,据我所知。



我研究调用 executeCommand 来尝试解决Spring Data的限制,但看起来他们甚至没有办法从原始命令执行它。


I don't know if I am doing something wrong or it is a bug. I have the following code:

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

I am executing the query and profiles near by retrieved correctly according to distance and the "locationTime" criteria but it seems to ignore the excluded field and retrieving the profiles with their friends.

When I use simple query the exclude/include fields works perfectly.
I looked every where and could not find any resemble use-case, please let me know if i am doing something wrong.

Thanks.

解决方案

There's no way to limit the fields with a geoNear command, as far as I know.

I looked into calling executeCommand to try to work around the limitations of Spring Data, but it looks like they don't even have a way to do it from the raw command.

这篇关于弹簧数据mongoDB几何查询与排除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆