Using geospatial commands in rethinkdb with changefeed

六眼飞鱼酱① 提交于 2021-02-07 04:33:05

问题


right now I have a little problem:

I want to use geospatial commands (like getIntersecting) together with the changefeed feature of rethinkdb but I always get:

RqlRuntimeError: Cannot call changes on an eager stream in: r.db("Test").table("Message").getIntersecting(r.circle([-117.220406,32.719464], 10, {unit: 'mi'}), {index: 'loc'})).changes()

the big question is: Can I use getIntersecting with the changes() (couldn't find anything related to that in the docs btw ...) or do I have to abandon the idea of using rethinkdb geospatial features and just use change() to get ALL added or changed documents and do the geospatial stuff outside of rethinkdb?


回答1:


You can't use .getIntersecting with .changes, but you can write essentially the same query by adding a filter after .changes that checks if the loc is within the circle. While .changes limits what you can write before the .changes, you write basically any query after the .changes and it will work.

r.table('Message')
  .changes()
  .filter(
    r.circle([-117.220406,32.719464], 10, {unit: 'mi'})
     .intersects(r.row('new_val')('loc'))
  )

Basically, every time there is a change in the table the update will get push to the changefeed, but it will get filtered out. Since there is not a lot of support for geospatial and changfeeds, this is more or less how you would need to integrate the two.

In the future, changefeeds will be much broader and you'll be able to write basically any query with .changes at the end.



来源:https://stackoverflow.com/questions/30549908/using-geospatial-commands-in-rethinkdb-with-changefeed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!