请教有关nGQL引用边的属性做比较的问题

  • nebula 版本:3.2.0
  • 部署方式:分布式
  • 安装方式: RPM
  • 是否为线上版本:Y
  • 硬件信息
    • 磁盘
    • CPU、内存信息 52C 256G
  • 问题的具体描述

match(:人)-[v1:入住时间]->(:room)<-[v2:]-(:人)

主要检索语句是这个如上

目前我的需求是想要判断一下v1与v2的时间差
(substr(v1.入住时间,1,2)==substr(v2.入住时间,1,2))

探索过程中发现无法调用到边的属性

请教match语句中如何调用边的属性值

边的属性不带 type 哈

(root@nebula) [basketballplayer]> 

MATCH (v:player)-[e:follow]-(v2) 
  WHERE id(v) == 'player100' AND e.degree > 85
RETURN v2.player.name, e.degree;

+-------------------+----------+
| v2.player.name    | e.degree |
+-------------------+----------+
| "Manu Ginobili"   | 90       |
| "Manu Ginobili"   | 95       |
| "Dejounte Murray" | 99       |
| "Tony Parker"     | 95       |
| "Tony Parker"     | 95       |
+-------------------+----------+
Got 5 rows (time spent 6242/20030 us)

更新了文档,增加了例子 Added an edge prop ref example in 2.match.md by wey-gu · Pull Request #2209 · vesoft-inc/nebula-docs-cn · GitHub

昂,就是不能按字符串来处理嘛。
我按照您的语法试了一下(return v1.rzsj)
返回的值都是BAD_TYPE

你的 入住时间 是 edge type?,里边的属性 rzsj 的类型是?

(root@nebula) [basketballplayer]>

MATCH (v:player)-[e:serve]->(v2) 
    WHERE id(v) == 'player100' and e.start_year > 1996
RETURN v2.team.name, e.start_year;
+--------------+--------------+
| v2.team.name | e.start_year |
+--------------+--------------+
| "Spurs"      | 1997         |
+--------------+--------------+
Got 1 rows (time spent 5768/14109 us)

入住时间是edge,rzsj(字符串)是它的属性

我在成语图谱里写了类似的表达,是可以的

(root@nebula) [chinese_idiom]> 
match (v)-[e1:with_pinyin_part]-(pt)-[e2:with_pinyin_part]-(v1) WHERE id(v) == "bao"
AND substr(e1.part_type, 2, 4) == substr(e2.part_type, 2, 4) 
RETURN v, v1 LIMIT 5

+------------------------------------+--------------------------------------+
| v                                  | v1                                   |
+------------------------------------+--------------------------------------+
| ("bao" :character_pinyin{tone: 0}) | ("zhao4" :character_pinyin{tone: 4}) |
| ("bao" :character_pinyin{tone: 0}) | ("zhao3" :character_pinyin{tone: 3}) |
| ("bao" :character_pinyin{tone: 0}) | ("zhao2" :character_pinyin{tone: 2}) |
| ("bao" :character_pinyin{tone: 0}) | ("zhao1" :character_pinyin{tone: 1}) |
| ("bao" :character_pinyin{tone: 0}) | ("zhao" :character_pinyin{tone: 0})  |
+------------------------------------+--------------------------------------+
Got 5 rows (time spent 16242/31983 us)

按照您的语法标准试了一下,解决了,感谢 :hugs:

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