【发布时间】:2020-04-29 18:21:42
【问题描述】:
我有一个具有以下架构的 Janusgraph 数据库:
(期刊)
我正在尝试使用 gremlin match() 子句编写查询,该子句将搜索两个不同的期刊和标题中带有关键字的相关论文和作者。这是我到目前为止所拥有的:
sg = g.V().match(
__.as('a').has('Journal', 'displayName', textContains('Journal Name 1')),
__.as('a').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').next()
此查询成功运行,但返回 0 个顶点和 0 个边。如果我将查询分成两部分并分别搜索每个 Journal displayName 我会得到完整的图表,所以我认为我的查询的逻辑/语法有问题。
如果我这样写查询:
sg = g.V().or(has('JournalFixed', 'displayName', textContains('Journal Name 1')),
has('JournalFixed', 'displayName', textContains('Journal Name 2'))).
inE('PublishedInFixed').subgraph('sg').
outV().has('Paper', 'paperTitle', textContains('My Key word')).
inE('AuthorOf').subgraph('sg').
outV().
cap('sg').
next()
它返回一个包含大约 7000 个节点的网络。如何重新编写此查询以使用 match() 子句?
【问题讨论】:
标签: gremlin graph-databases janusgraph