如何返回OrientDB图形中不带';你没有特定的后代吗?
例如,在以下树结构中:如何返回OrientDB图形中不带';你没有特定的后代吗?,orientdb,Orientdb,例如,在以下树结构中: root (name = a) (name = b) (name = c) (name = a) (name = x) ... (name = c) (name = a) (name = c) (name = a) (name = e) 其中,图形中只有一种类型的边称为HAS\u CHILD。例如,从root到第一个c节点的路径是: root-HAS_CHILD-&g
root
(name = a)
(name = b)
(name = c)
(name = a)
(name = x)
...
(name = c)
(name = a)
(name = c)
(name = a)
(name = e)
其中,图形中只有一种类型的边称为HAS\u CHILD
。例如,从root
到第一个c
节点的路径是:
root-HAS_CHILD->a-HAS_CHILD->b-HAS_CHILD->c
我想返回所有名为a
的节点,这些节点没有名为c
的后代。在本例中,这将是名为a
的第四个节点
XPath等价物类似于:
//*[not(.//*[contains(@name, 'c')])]
也许有一种更有效的方法,但这应该有效:
select from node where (name='a') and (@rid not in (select from (traverse in('has_child') from ( select from node where name='c') ) where name='a'))