V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hunk
V2EX  ›  Java

spring 中使用 redis 搜索附近位置总是返回为空

  •  
  •   hunk · 230 天前 · 598 次点击
    这是一个创建于 230 天前的主题,其中的信息可能已经有所发展或是发生改变。

    Spring 加载时从数据库读取数据写入 redis ,使用命令行可以返回结果 geosearch project:locs fromlonlat 112.xx 32.xx BYRADIUS 200 km WITHDIST ASC

      1. "9"
    1. "1.3747"
      1. "11"
      2. "2.2997"
      1. "10"
      2. "2.4876"

    但在程序中始终结果为 0 ,请帮忙分析下是什么原因?

        String key = "project:locs";
    
        GeoResults<RedisGeoCommands.GeoLocation<String>> results = redisTemplate.opsForGeo().search(
                key,
                GeoReference.fromCoordinate(112.xx,32.xx),
                new Distance(5000000, Metrics.KILOMETERS),
                RedisGeoCommands.GeoSearchCommandArgs.newGeoSearchArgs().includeDistance().limit(100));
    
        List<GeoResult<RedisGeoCommands.GeoLocation<String>>> content = results.getContent();
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1478 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:05 · PVG 01:05 · LAX 10:05 · JFK 13:05
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.