分配给一个子图的Gremlin中的节点属性的“或"运算符 [英] 'Or' operator for node properties in Gremlin assigned to one subgraph

查看:268
本文介绍了分配给一个子图的Gremlin中的节点属性的“或"运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Janusgraph数据库,其中包含带有标签纸",节点属性"paperTitle"和"year"以及边类型"References"的节点.

I have a Janusgraph database which contains nodes with the label 'Paper', the node properties 'paperTitle' and 'year' and the edge type 'References'.

我正在尝试编写一个查询,该查询将允许我按标题及其所有参考文献选择两篇论文,并将结果分配给子图.

I'm trying to write a query that will allow me to select two papers by title and all their references and assign that result to a subgraph.

我可以使用两种条件选择一张纸:

I can select one paper using two conditions like this:

sg = g.V().
     and(has('Paper', 'paperTitle', 'ladle pouring guide'), has('Paper', 'year', '1950')).
     inE('References').
     subgraph('sg1').
     cap('sg1').
     next()

使用该查询作为我的起点,我希望可以做到这一点:

Using this query as my starting point I had hoped I could do this:

sg = g.V().
     or(has('Paper', 'paperTitle', 'ladle pouring guide'), has('Paper', 'paperTitle', 'the development of the human mandibular joint')).
     inE('References').
     subgraph('sg1').
     cap('sg1').
     next()

但是这将返回一个具有0个节点和0个边的子图.

But this returns a subgraph with 0 nodes and 0 edges.

我在Janusgraph文档 http://tinkerpop中看到了此页面. apache.org/docs/current/reference/#or-step ,但似乎仅描述了多个边的选择,而不是多个节点属性.

I saw this page in the Janusgraph documentation http://tinkerpop.apache.org/docs/current/reference/#or-step but it seems to only describe selections of multiple edges not multiple node properties.

是否可以创建这种子图,还是需要将它们作为两个单独的查询运行?

Is it possible to create this kind of subgraph or do I need to runs these as two separate queries?

推荐答案

我不明白为什么你不能在一个查询中做到这一点,而且我不确定为什么遍历不起作用,但是我会写它是:

I don't see why you can't do this in one query and I'm not sure why your traversal doesn't work, however I would write it as:

sg = g.V().
     has('Paper', 'paperTitle', within('ladle pouring guide', 
                                       'the development of the human mandibular joint')).
     inE('References').
     subgraph('sg1').
     cap('sg1').
     next()

这篇关于分配给一个子图的Gremlin中的节点属性的“或"运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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