怎么实现or查询

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

其他看起来应该是支持的,再就是判断相等是 == 不是 =,可以自己写写看

如 Jerry 问的,如果 42db90fb47e843978a66f7e3ea723b0f 是点的 id,加一个条件

where id(n) == “42db90fb47e843978a66f7e3ea723b0f” 就可以查询了

如果 42db90fb47e843978a66f7e3ea723b0f 是一个 tag(类似于 neo4j 里的 label),那么这个查询的起点需要为 点的属性创建索引哈


怎么查询nebula属性值为null的数据,列如nebula_5E74_9F84属性为NULL,怎么用语句查询出来?

NULL 在 MATCH 里用 IS 、IS NOT 做比较


试过了,nebula_5E74_9F84是数值类型,查询不出来

看截图是 == 不是 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


除了这种办法有其他办法么,我现在是这么处理的,担心tag较多,语句较长,就查询不出来了

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语法

已经有PR了,6月30号的版本会带入 https://github.com/vesoft-inc/nebula/pull/4071

2 个赞

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。