我正在尝试了解Neo4J;而且我完全挠挠脑袋 基本上我有以下cypher查询,它基于一些正则表达式查询从我的图表中选择一些节点,这些查询特意是最多4个链接/节点。
我希望能够做的是返回路径和连接这些节点的其他节点。
MATCH (n)
WHERE any(prop in keys(n) where n[prop] =~ "(?i)4567890123456789-0.*")
OR any(prop in keys(n) where n[prop] =~ "(?i)3456789012345678.*")
OR any(prop in keys(n) where n[prop] =~ "(?i)1234567890123456.*")
MATCH path = (s)-[r*0..4]-(f)
// Here
RETURN path, n
我认为我需要的是像
MATCH path = (s)-[r*0..4]-(f)
// WHERE s IN(n) AND f IN(n)
RETURN path, n
我可能在这里是个大笨蛋...
更新 我有点设法让它像这样工作:
MATCH (n)
WHERE any(prop in keys(n) where n[prop] =~ "(?i)4567890123456789-0.*")
OR any(prop in keys(n) where n[prop] =~ "(?i)3456789012345678.*")
OR any(prop in keys(n) where n[prop] =~ "(?i)1234567890123456.*")
WITH collect(n) as valid
MATCH path = (s)-[r*0..3]-(f)
WHERE s in valid
AND f in valid
RETURN path
但是现在我也需要返回悬空节点,哈哈:)好玩