不能将CompositeFilter与4个FilterPredicate值一起使用

时间:2012-08-07 01:57:51

标签: java google-app-engine google-cloud-datastore

我正在构建一个程序,它将通过GAE数据存储搜索具有纬度和经度参数的特定地理定位块内的用户,下面是代码snipet:

public Iterable<Entity> GetJSONForEntitiyNearByUsingBounds(float lng,float     lat,GeoLocation.GeoLocationBoundry bound)
{
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();

    Filter filter_min_lngt=new FilterPredicate("lng", FilterOperator.LESS_THAN, bound.lng1);
    Filter filter_max_lngt=new FilterPredicate("lng", FilterOperator.LESS_THAN, bound.lng2);
    Filter filter_min_lat=new FilterPredicate("lat", FilterOperator.GREATER_THAN, bound.lat1);
    Filter filter_max_lat=new FilterPredicate("lat", FilterOperator.LESS_THAN, bound.lat2);

    Filter filter_lng=new CompositeFilter(CompositeFilterOperator.AND,Arrays.asList(filter_min_lngt,filter_max_lngt));
    Filter filter_lat=new CompositeFilter(CompositeFilterOperator.AND,Arrays.asList(filter_min_lat,filter_max_lat));


    Filter filter=new CompositeFilter(CompositeFilterOperator.AND,Arrays.asList(filter_lng,filter_lat));

    q.setFilter(filter);

    PreparedQuery pq = datastore.prepare(q);


    return pq.asIterable();
}

是当我循环查询以提取实体时,出现以下消息 java.lang.IllegalArgumentException:每个查询只支持一个不等式过滤器。遇到了lng和lat

有人可以帮助我,因为我不知道是什么问题

1 个答案:

答案 0 :(得分:1)

请参阅Restrictions on Queries:它明确指出不一致的文件管理器一次只能在一个属性上使用。

问题的解决方案是地理位置:https://stackoverflow.com/search?q=%5Bgoogle-app-engine%5D+geohashing