在rethinkdb和changefeed中使用地理空间命令 [英] Using geospatial commands in rethinkdb with changefeed

查看:40
本文介绍了在rethinkdb和changefeed中使用地理空间命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个小问题:

我想将地理空间命令(如getIntersecting)与rethinkdb的changefeed功能一起使用,但我总是得到:

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

RqlRuntimeError:无法在以下急切的流上调用 changes :r.db("Test").table("Message").getIntersecting(r.circle([-117.220406,32.719464],10,{unit:'mi'}),{index:'loc'})).changes()

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()

最大的问题是:我可以将getIntersecting与changes()一起使用(在文档btw中找不到与之相关的任何内容吗?)还是我不得不放弃使用rethinkdb地理空间特征的想法,而只使用change()获取所有已添加或已更改的文档,是否在rethinkdb之外进行了地理空间工作?

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?

推荐答案

您不能将 .getIntersecting .changes 一起使用,但是可以编写基本相同的查询通过在 .changes 之后添加 filter 来检查 loc 是否在圆内.虽然 .changes 限制了您可以在 .changes 之前编写的内容,但是您基本上可以在 .changes 之后编写任何查询,并且该查询可以正常工作.

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'))
  )

基本上,每次表中有更改时,更新将被推送到changefeed,但它将被滤除.由于对地理空间和changfeed的支持不多,因此这或多或少是您将两者整合在一起的方式.

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.

将来,changefeeds的范围将更加广泛,您基本上可以使用结尾处的 .changes 编写任何查询.

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

这篇关于在rethinkdb和changefeed中使用地理空间命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆