带有 whereNear() 的 ParseQuery 忽略其他条件

ParseQuery with whereNear() ignores others conditions

下面的查询完全忽略了第二个条件(filter,即字符串字段)。

但是当 whereNear() 条件被注释时,过滤器被应用。

whereNear()条件是否会导致忽略其他条件? 如果是,在这种情况下正确的方法是什么?

ParseQuery<ParseObject> query = ParseQuery.getQuery("Post");
query.whereNear("location", new ParseGeoPoint(latitude, longitude));
query.whereEqualTo("filter", filter);
query.orderByDescending("createdAt");
List<ParseObject> objects = query.find()

whereNear() 不应该是 whereEqualTo() 被忽略的原因(我有一个与你的应用程序条件相同的应用程序,它工作正常)。您更愿意关注 orderByDescending(),因为它优先于 whereNear()。

注意:根据解析文档,应用了额外的 orderByAscending()/orderByDescending() 约束,它将优先于距离排序。

来自解析 documentation

If an additional orderByAscending()/orderByDescending() constraint is applied with whereNear(), it will take precedence over the distance ordering.

因此,whereNear() 不会覆盖 orderByDescending()。恰恰相反。另外,

Using the whereNear() constraint will also limit results to within 100 miles.

如果给定点附近100英里内没有满足第二个过滤器的点。我认为这就是为什么你会得到意想不到的结果。