在neo4j上我有这样的错误:预期路径但是收集<路径>?

时间:2015-06-15 12:13:49

标签: neo4j cypher

我目前正在使用neo4j。我试图通过neo4j研究图形数据库。对于我的学习,我需要执行一些查询。我遇到了这个问题:

Match path = (a:Node)-[:Rel1|Rel2*7..8]-(b:Node), (c:Node)

Where (a:Node)-[:Rel1|Rel2*7..8]-(b:Node) and (a:Node)-[:Rel1|Rel2*7..8]-(c:Node) and (b:Node)-[:Rel1|Rel2*7..8]-(c:Node)

With a as aa, b as bb, c as cc, (a:Node)-[:Rel1|Rel2*7..8]-(b:Node) as path1,
(a:Node)-[:Rel1|Rel2*7..8]-(c:Node) as path2, (c:Node)-[:Rel1|Rel2*7..8]-(b:Node) as path3

Limit 1

With a as aa, b as bb, c as cc,
path1 as path1, path2 as path2, path3 as path3, Extract(rel in relationships(path1) | rel.id) as relIDs1, Extract(rel in relationships(path2) | rel.id) as relIDs2, Extract(rel in relationships(path3) | rel.id) as relIDs3

Return path1, path2, path3

我遇到第二个问题,neo4j确实返回一条路径(我只需要1个路径“限制1”)当我评论这一行时,但当我试图做那个预期的路径但是收集时该提取物。我怎么能处理这个问题,我试着看一下我不知道的文档。

非常感谢!

1 个答案:

答案 0 :(得分:0)

Neo4j的行为是将数据作为Collection返回,即使只有一个项目。如果返回类型不一致会更加混乱,所以这确实是件好事。只需从集合中获取第一个元素,将其存储在Path类型变量中,然后继续。