Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Variables Cypher:变量有效的匹配语句的范围_Variables_Scope_Neo4j_Match_Cypher - Fatal编程技术网

Variables Cypher:变量有效的匹配语句的范围

Variables Cypher:变量有效的匹配语句的范围,variables,scope,neo4j,match,cypher,Variables,Scope,Neo4j,Match,Cypher,我想我在理解匹配的结构和匹配变量所在的范围方面有一个普遍的问题 我遇到问题的具体代码是: // S sentiment toward A goodFor/badFor T // => S sentiment toward the idea of A goodFor/badFor T MATCH (S:A)-[:SOURCE]->(sent1:PS {type:"sentiment"})-[:TARGET]->(gfbf:E {type:"gfbf"}) , (A)-[:SO

我想我在理解匹配的结构和匹配变量所在的范围方面有一个普遍的问题

我遇到问题的具体代码是:

// S sentiment toward A goodFor/badFor T 
// => S sentiment toward the idea of A goodFor/badFor T

MATCH (S:A)-[:SOURCE]->(sent1:PS {type:"sentiment"})-[:TARGET]->(gfbf:E {type:"gfbf"}) , (A)-[:SOURCE]->(gfbf)-[:TARGET]->(T) , (Writer:A {type:"writer"})
// if there is some negative belief in any of the writers private state spaces that involve gfbf then inference is blocked
WHERE NOT (Writer)-[*1..]->({type:"believesTrue" , spec:FALSE})-[*1..]->(gfbf)
// if sent1 is in some private state spaces of the writer return all of these
OPTIONAL MATCH p=(Writer)-[*]->(sent1)
WITH NODES(p)[1..-1] AS ps_nodes
WHERE ALL(x IN ps_nodes[1..] WHERE LABELS(x) = "PS")

MERGE (S)-[:SOURCE]->(sent2:PS {type:"sentiment" , spec:(sent1.spec)})-[:TARGET]->(ideaOf:I {name:"ideaOf" , type:"ideaOf"})-[:TARGET]->(gfbf)

ON CREATE SET sent2.name = 
CASE sent2.spec
WHEN FALSE THEN "-S"
ELSE "+S"
END

RETURN p
我认为理解这是为了什么并不重要。只要看看我假设的结构就足够了,但基本上它的作用是:它查找一个子图,其中有路径
S-->sent1-->gfbf
,还有路径
a-->gfbf-->T
。如果它发现它使一个新路径
a-->sent2-->ideaOf-->gfbf
,则在根据匹配节点的属性设置新节点的属性时,所有这些操作都会执行。此外,它还查看它是否还有一个路径
writer-->…-->sent
,其中
..
部分中的所有节点都有标签
PS
。如果找到该路径,则返回该路径,以便在程序的不同部分执行进一步的操作

我得到的错误是:

py2neo.cypher.error.statement.InvalidSyntax: sent1 not defined (line 6, column 58 (offset: 421))
"MERGE (S)-[:SOURCE]->(sent2:PS {type:"sentiment" , spec:(sent1.spec)})-[:TARGET]->(ideaOf:I {name:"ideaOf" , type:"ideaOf"})-[:TARGET]->(g"bf)

为什么
sent1
不再在我使用它的地方定义,我需要如何重新构造代码以使其有效?

sent1 in不在前面的中,请将其更改为:

WITH NODES(p)[1..-1] AS ps_nodes, sent1