尝试了解MATCH和WHERE中的标识符和集合 [英] Trying to understand identifiers and collections in MATCH and WHERE

查看:221
本文介绍了尝试了解MATCH和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;

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子句的要求是什么.也许您可以通过编辑问题来澄清问题.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆