或语句与Gremlin中的匹配语句
我有一个Janusgraph数据库,其模式如下:或语句与Gremlin中的匹配语句,gremlin,graph-databases,janusgraph,Gremlin,Graph Databases,Janusgraph,我有一个Janusgraph数据库,其模式如下: (Journal)我不确定这是否都是您的问题,但我认为您的match()是将您的“displayName”步骤建模为和(),而不是或()。您可以使用profile()进行检查,就像我在这里使用TinkerGraph所做的那样: gremlin> g.V().match(__.as('a').has('name','marko'), __.as('a').has('name','josh')).profile() ==>Traversa
(Journal)我不确定这是否都是您的问题,但我认为您的
match()
是将您的“displayName”步骤建模为和()
,而不是或()
。您可以使用profile()
进行检查,就像我在这里使用TinkerGraph所做的那样:
gremlin> g.V().match(__.as('a').has('name','marko'), __.as('a').has('name','josh')).profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
TinkerGraphStep(vertex,[name.eq(marko), name.eq... 0.067 100.00
>TOTAL - - 0.067 -
我想你可以用多种方法来解决这个问题。在我的示例中,在()中使用
,如对的不同回答中所述,效果很好:
gremlin> g.V().match(__.as('a').has('name', within('marko','josh'))).profile()
==>Traversal Metrics
Step Count Traversers Time (ms) % Dur
=============================================================================================================
TinkerGraphStep(vertex,[name.within([marko, jos... 2 2 0.098 100.00
>TOTAL - - 0.098 -
对于您的情况,我将替换:
or(has('JournalFixed', 'displayName', textContains('Journal Name 1')),
has('JournalFixed', 'displayName', textContains('Journal Name 2')))
与:
基本上利用了p.或()
。我认为这两个选项中的任何一个都应该比使用或()
-提前一步好,但是只有JanusGraph的概要文件()
才能说明问题
综上所述,我想知道为什么你的或()
g.V().match(
__.as('a').or(has('Journal', 'displayName', textContains('Journal Name 1')),
has('Journal', 'displayName', textContains('Journal Name 2'))),
__.as('a').inE('PublishedIn').subgraph('sg').outV().as('b'),
__.as('b').has('Paper', 'paperTitle', textContains('My Key word')),
__.as('b').inE('AuthorOf').subgraph('sg').outV().as('c')).
cap('sg')
尽管如此,我想我的p.或()
的建议更有效 谢谢,斯蒂芬,这很有帮助。另外,我不知道profile()
,我认为这会有帮助。我真的很感谢你的帮助,因为我开始对付小精灵
or(has('JournalFixed', 'displayName', textContains('Journal Name 1')),
has('JournalFixed', 'displayName', textContains('Journal Name 2')))
has('JournalFixed', 'displayName', textContains('Journal Name 1').
or(textContains('Journal Name 2'))
g.V().match(
__.as('a').or(has('Journal', 'displayName', textContains('Journal Name 1')),
has('Journal', 'displayName', textContains('Journal Name 2'))),
__.as('a').inE('PublishedIn').subgraph('sg').outV().as('b'),
__.as('b').has('Paper', 'paperTitle', textContains('My Key word')),
__.as('b').inE('AuthorOf').subgraph('sg').outV().as('c')).
cap('sg')