gpt4 book ai didi

neo4j - 试图理解 MATCH 和 WHERE 中的标识符和集合

转载 作者:行者123 更新时间:2023-12-04 06:58:00 25 4
gpt4 key购买 nike

我试图了解某些标识符或表达式对应于哪种密码“数据结构”,具体取决于它们的使用方式和位置。
下面我列出了我遇到的例子。请告诉我我是否做对了(在评论中)或者我是否遗漏了什么。

MATCH (a:MYTYPE { label:'l_a' })
// a corresponds to a collection of nodes

MATCH (b:MYTYPE { label:'l_b' })
// so does b

MATCH p=(a)-[sp1:CF*]->(b)-[sp12:CF]->(c)
// p corresponds to a collection of paths
// a and b correspond to a collection of nodes
// (or does the previous MATCH of a and b change something?)
// sp1 corresponds to a collection of collections of relationships
// sp12 corresponds to a collection of relationships
// c corresponds to a collection of nodes

WHERE ( p = ... )
// Here, the p corresponds to a path, i.e. there must be a path or (I don't know) on the right side of the =
WHERE ( a = ... )
// a corresponds to a node, i.e. there must be a node on the right side of the =
WHERE ( sp1 = ... )
// sp1 corresponds to a collection of nodes, i.e. there must be a collection of relationships on the right side

//BONUS:
WHERE ( (e)-[sp2:CF*]->(f) ) = ...
// there must be a collection of collections of paths on the right side of the =

最佳答案

我认为回答所有这些问题的最简单方法是将标识符传递给函数,这些函数会抛出一个错误,告诉您它期望什么以及它实际收到什么。我认为你也应该注意你如何使用这个词集合,因为它是不正确的。

节点、关系、路径
MATCH (n) RETURN n;nNode .
MATCH ()-[r]-() RETURN r;rRelationship .
MATCH p = ()-[]-()pPath .

收藏
MATCH (n) WITH COLLECT(n) AS c RETURN c;cCollection<Node> .
MATCH ()-[r]-() WITH COLLECT(r) AS c RETURN c;cCollection<Relationship> .
MATCH p = ()-[]-() WITH COLLECT(p) AS c RETURN c;cCollection<Path> .

可变长度路径
MATCH p = ()-[r*..2]-() RETURN p, r;pPath .
rCollection<Relationship> .

并引用您的具体示例:
MATCH p = (a)-[sp1:CF*]->(b)-[sp12:CF]->(c)pPath .
aNode .
sp1Collection<Relationship> .
bNode .
sp12Relationship .
cNode .

而且我不确定你在问什么 WHERE条款。也许您可以通过编辑您的问题来澄清。

关于neo4j - 试图理解 MATCH 和 WHERE 中的标识符和集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33655824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com