英文:
Query user id by limit based on distance using georadius
问题
StackOverflow社区,
我正在开发一个Flink Java应用程序来查询用户之间的距离。我正在使用lettuce框架查询给定位置的userID,具体命令如下:
GEORADIUS <location> <lat> <lon> <radius> <unit>。
条件 -> 现在想象一下,在给定的参数范围内有数百万个userID。
问题 -> 在不在单个查询中查询数百万用户的情况下,使用lettuce框架查询用户ID的最佳方法是什么?
我知道有排序的集合可以通过limit
来无缝地跟踪最后的偏移量,并从那一点继续查询。然而,geo API提供了count
,它只提供前n个userID。是否有类似的方法可以使用georadius命令实现?
或者是否有更好的方法来解决这个问题,我们可以在给定的半径范围内查询userID,而不会重复返回结果?我知道我们可以减小距离,但是否有办法获取r1和r2之间的增量?
英文:
StackOverflow community,
I am working on a Flink java application to query distance between users. I am using the lettuce framework to query userID given
GEORADIUS <location> <lat> <lon> <radius> <unit>.
Condition -> Now imagine there are millions of userID within given parameters.
Question -> What would be the best way to query the user ids using the lettuce framework while not querying a million users in a single query?
I know sorted sets have limit
via which we can seamlessly keep track of the last offset and continue querying from that point. However, geo API provides count
which provides only top n userID. Is there something similar we can do using georadius command?
Or is there a better way to solve the problem, where we can query userID without repeating results within given radius bounds?
I know we can reduce distance but, is there a way to gat delta between r1 and r2?
答案1
得分: 0
你可以使用 GEORADIUS
命令,并带上 STORE
或者 STOREDIST
选项,将结果保存到有序集合中。然后,你可以使用 ZRANGE
命令来遍历这个结果。
英文:
You can call GEORADIUS
command with STORE
or STOREDIST
options to save the result into a sorted set. Then you can use the ZRANGE
command to iterate the result.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论