尝试了解MATCH和WHERE中的标识符和集合 [英] Trying to understand identifiers and collections in MATCH and WHERE
问题描述
我试图了解某些标识符或表达式对应于哪种密码数据结构",具体取决于如何使用它们以及在何处使用它们. 下面,我列出了我遇到的示例.请告诉我我是否正确(在评论中)或我缺少什么.
I am trying to understand to what kind of cypher "data structure" certain identifiers or expressions correspond to, depending on how and where they are used. Below I list examples I encountered. Please tell me if I got it right (in the comments) or if I am missing something.
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 =
推荐答案
我认为回答所有这些问题的最简单方法是将标识符传递给函数,该函数会引发错误,告诉您期望值和实际接收值.我认为您还应该谨慎使用单词集合,因为它是不正确的.
I think the easiest way to answer all these questions is by passing identifiers to functions that will throw an error telling you what it expected and what it actually received. I think you should also be careful about how you use the word collection, as it is not correct.
MATCH (n) RETURN n;
n
是Node
.
MATCH ()-[r]-() RETURN r;
r
是Relationship
.
MATCH p = ()-[]-()
p
是Path
.
MATCH (n) WITH COLLECT(n) AS c RETURN c;
c
是Collection<Node>
.
MATCH ()-[r]-() WITH COLLECT(r) AS c RETURN c;
c
是Collection<Relationship>
.
MATCH p = ()-[]-() WITH COLLECT(p) AS c RETURN c;
c
是Collection<Path>
.
MATCH p = ()-[r*..2]-() RETURN p, r;
p
是Path
.
r
是Collection<Relationship>
.
并参考您的特定示例:
MATCH p = (a)-[sp1:CF*]->(b)-[sp12:CF]->(c)
p
是Path
.
a
是Node
.
sp1
是Collection<Relationship>
.
b
是Node
.
sp12
是Relationship
.
c
是Node
.
我不确定您对WHERE
子句的要求是什么.也许您可以通过编辑问题来澄清问题.
And I'm not sure what you're asking about the WHERE
clauses. Perhaps you can clarify with an edit to your question.
这篇关于尝试了解MATCH和WHERE中的标识符和集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!