match (n:42db90fb47e843978a66f7e3ea723b0f
) where 1=1 and ( not '人物’in labels(n) or ( n.年龄=~ ‘.14.’ and ‘人物’ in labels(n))) and ( not '人物’in labels(n) or ( n.工作年限=~ ‘.2.’ and ‘人物’ in labels(n))) and ( not '部门’in labels(n) or ( n.人数=~ ‘.1.’ and ‘部门’ in labels(n))) return n
这种neo4j语句nebula怎么实现,人物和部门是tag,后面是跟条件查询
match (n:42db90fb47e843978a66f7e3ea723b0f)
where
( not '人物’in labels(n) or ( n.年龄=~ ‘.14.’ and ‘人物’ in labels(n)))
and
( not '人物’in labels(n) or ( n.工作年限=~ ‘.2.’ and ‘人物’ in labels(n)))
and
( not '部门’in labels(n) or ( n.人数=~ ‘.1.’ and ‘部门’ in labels(n))) return n
- 正则表达
=~
是支持的 ref: 字符串运算符 - Nebula Graph Database 手册 - 属性条件的表达有区别,需要
n.人物.年龄 > 15
这样写
其他看起来应该是支持的,再就是判断相等是 ==
不是 =
,可以自己写写看
如 Jerry 问的,如果 42db90fb47e843978a66f7e3ea723b0f
是点的 id,加一个条件
where id(n) == “42db90fb47e843978a66f7e3ea723b0f” 就可以查询了
如果 42db90fb47e843978a66f7e3ea723b0f
是一个 tag(类似于 neo4j 里的 label),那么这个查询的起点需要为 点的属性创建索引哈
NULL 在 MATCH 里用 IS 、IS NOT 做比较
看截图是 ==
不是 IS
呀?
(root@nebula) [basketballplayer]> match (n:player) where n.player.name == "Tim Duncan" AND n.player.age IS NOT NULL return n
+----------------------------------------------------------------------------------------+
| n |
+----------------------------------------------------------------------------------------+
| ("player100" :player{age: 42, name: "Tim Duncan"} :actor{age: 42, name: "Tim Duncan"}) |
+----------------------------------------------------------------------------------------+
Got 1 rows (time spent 10143/17391 us)
match (n:42db90fb47e843978a66f7e3ea723b0f
) where n.名称=~’..’ return n.名称 LIMIT 10
这种neo4j语法,nebula能实现么,就是查询图谱所有名称的数据,不指定tag
match (n:42db90fb47e843978a66f7e3ea723b0f
) where n.名称=~’..’ return n.名称 LIMIT 10
42db90fb47e843978a66f7e3ea723b0f 是图谱id,没有指定tag查询出图谱内所有名称的数据
图谱 id 是什么意思是点的id么?
整个图谱的id,不是点id
ok,在 Nebula 里这个可以对应到图空间。
USE 42db90fb47e843978a66f7e3ea723b0f
match (n) where n.player.name == "xxx" return n
如果想匹配不同属性相同属性名字的条件,只能用 union 去拼接所有的要考虑的 tag
比如
match (n:team) where properties(n).name starts with "T" return n limit 10 \
union \
match (n:player) where properties(n).name starts with "T" return n limit 10
MATCH p1 = shortestpath((:42db90fb47e843978a66f7e3ea723b0f
{名称:‘12’})-[r*]-(:42db90fb47e843978a66f7e3ea723b0f
{名称:‘23’})) with p1 MATCH p2 = shortestpath((:42db90fb47e843978a66f7e3ea723b0f
{名称:‘23’})-[r*]-(:42db90fb47e843978a66f7e3ea723b0f
{名称:‘124’})) with p1, p2, size(relationships(p1)) as psize1, size(relationships(p2)) as psize2 return psize1+psize2 as total order by total asc limit 1
问下nebula有neo4j这种语法,查询neo4j节点之间的最短路径么?42db90fb47e843978a66f7e3ea723b0f是图谱id,不是tag
shortestpath可以参考FIND PATH语法
此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。