You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Cypher查询中使用点运算符与RETURN语句:为何返回"Yes!"?

为什么这个Apache AGE查询会返回"Yes!"?

查询代码

SELECT *
FROM cypher('graph_name', $$
    MATCH (`This isn\'t a common variable`)
    WHERE `This isn\'t a common variable`.name = 'A'
    RETURN `This isn\'t a common variable`.happy
$$) as (happy agtype);

查询结果

| happy   |
——————————-
| "Yes!"  |
——————————-
| (1 row) |

原因解释

  • 在Apache AGE的Cypher语法里,用反引号()包裹的字符串可以作为合法的节点变量名,哪怕变量名包含空格、特殊字符或者单引号都能正常识别,这里的This isn't a common variable`就是一个合规的节点变量。
  • 这个查询的逻辑拆解:
    1. MATCH (This isn't a common variable):匹配目标图graph_name里的所有节点,将每个节点绑定到这个特殊变量上。
    2. WHERE This isn't a common variable.name = 'A':筛选出name属性值为'A'的节点。
    3. RETURN This isn't a common variable.happy:返回符合筛选条件节点的happy属性值。

返回结果为"Yes!",说明你的图graph_name中确实存在一个节点:它的name属性是'A',且happy属性的值就是"Yes!"。

内容的提问来源于stack exchange,提问作者Peter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 09:27:29