使用以下代码添加地理数据
jedis.geoadd("storegeodata", 51.5074, 0.1278, "London");
//while member string is mostly json
jedis.geoadd("storegeodata", 51.5074, 0.1278, "{place: London}");
jedis.geoadd("storegeodata", 51.5074, 0.1278, "{place: London, lat: 51.5074, lon: 0.1278}");
当geohash由于成员字符串不同而被复制时,如何检索基于geohash的唯一值以避免冗余
public Map<String, Object> checkRedisGeo(double lat, double lon, Jedis j) {
Map<String, Object> result = new HashMap<>();
try
{
GeoRadiusParam param = GeoRadiusParam.geoRadiusParam();
param.sortAscending();
param.withDist();
param.count(1);
System.out.println("lat :"+lat+" , lon :"+lon);
List<GeoRadiusResponse> response = j.georadius("commander",
lon,lat, 150, GeoUnit.M, param);
//System.out.println(response.size()+" size");
if(response.size() > 0)
{
for (GeoRadiusResponse geoRadiusResponse : response) {
System.out.println("lat :"+lat+" , lon :"+lon+", stringmember :"+geoRadiusResponse.getMemberByString());
//System.out.println(geoRadiusResponse.getDistance());
Object[] data= {geoRadiusResponse.getMemberByString()};
System.out.println(data);
result.put("result", data);
}
}else {
// sendEvents(streamEvent, null, streamEventChunk);
System.out.println("E");
}
} catch (Exception e) {
LOGGER.error("checkRedisGeo err : "+e);
}
return result;
}
哪个检索结果但如何根据geohash/score值过滤掉,如何得到所有不同的分数?
下面是冗余数据示例
1条答案
按热度按时间cwtwac6a1#
通过比较分数可以得到重复的和唯一的分数,因为分数是唯一的,并且为同一个分数存储了多个成员,下面是同一个分数的代码