在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`就是一个合规的节点变量。 - 这个查询的逻辑拆解:
MATCH (This isn't a common variable):匹配目标图graph_name里的所有节点,将每个节点绑定到这个特殊变量上。WHEREThis isn't a common variable.name = 'A':筛选出name属性值为'A'的节点。RETURNThis isn't a common variable.happy:返回符合筛选条件节点的happy属性值。
返回结果为"Yes!",说明你的图graph_name中确实存在一个节点:它的name属性是'A',且happy属性的值就是"Yes!"。
内容的提问来源于stack exchange,提问作者Peter
相关产品推荐
相关产品推荐

