如何在 GREMLIN 中找到具有条件的两个子顶点的父顶点?

How to find parent vertex of two child vertices with condition in GREMLIN?

我有下图:

          V1
       /  |  \
      p1  p2  p3

如果我有 p1 和 p3 顶点符合 GREMLIN 中的条件,我想找到父顶点 (V1)。 对于单亲,我有大约 25 个子节点。我需要找到任何子顶点符合条件的父节点。

例如:如果 P1、P2、P3 顶点具有以下属性 - 名称、值。 我需要找到像这样的父顶点:

SELECT 
   V1
WHERE 
       P1.name = 'a' and P1.value = 'b'
   AND P3.name = 'x' and P3.value = 'y'

(或)

SELECT 
   V1
WHERE 
       P2.name = 'p' and P2.value = 'q'
   AND P3.name = 'x' and P3.value = 'y'

解决此问题的最佳方法是命令式(任意选择一个子顶点作为开始)。

下面是此类查询的最简单形式:

g.V().has('Child','name','p1').in('HAS').where(out('HAS').has('name','p2'))

该查询的结果将是 V1