Neo4j Cypher使用'和/或'从集合中提取数据逻辑运算符

时间:2015-06-06 02:56:18

标签: collections neo4j cypher extract logical-operators

我有一个集合,我需要从每个节点中提取名称和ID并将它们一起返回以避免后期处理。我在尝试:

extract(c IN nodes(c)| c.name +\': \'+ c.id) as results

问题是当遇到没有名称值的节点时,它不会返回任何内容。

有没有像'和/或'使c.name可选,允许它仍然返回c.name和NULL为c.name?

由于

1 个答案:

答案 0 :(得分:1)

我一开始会想到你可以使用toString将空值转换为空字符串,但这似乎不起作用。 coalesce应该有所帮助,但是:

extract(c IN nodes(c)| coalesce(c.name, '') +\': \'+ c.id) as results