Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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
Neo4j 如何向用户指出哪里出了问题_Neo4j_Cypher - Fatal编程技术网

Neo4j 如何向用户指出哪里出了问题

Neo4j 如何向用户指出哪里出了问题,neo4j,cypher,Neo4j,Cypher,所以我有一个很好的问题: MATCH (c:Character)-[r1:IS_LOCATED_IN]->(l1:Location) where c.name=$char MATCH (l1:Location)-[r2:IS_CONNECTED_TO]->(l2:Location) where l2.name=$newlocation and c.turns >= r2.cost and l1 <> l2 SET c.turns = c.turns - r2

所以我有一个很好的问题:

MATCH (c:Character)-[r1:IS_LOCATED_IN]->(l1:Location) where c.name=$char
MATCH (l1:Location)-[r2:IS_CONNECTED_TO]->(l2:Location) where
    l2.name=$newlocation and c.turns >= r2.cost and l1 <> l2
SET c.turns = c.turns - r2.cost
DELETE r1
CREATE (c)-[:IS_LOCATED_IN]->(l2)
return c,l2

在这种情况下,您可以使用
可选匹配
以及结尾处的
案例
语句来评估可能的场景

例如。。。而不是

MATCH (c:Character)-[r1:IS_LOCATED_IN]->(l1:Location) where c.name=$char
你可以有一个

OPTIONAL MATCH (c:Character)-[r1:IS_LOCATED_IN]->(l1:Location) where c.name=$char
WITH c
...
RETURN CASE
    WHEN c IS NULL THEN "Character not found"
    ELSE "something else
END AS message

当字符或位置等不匹配时,您还有一些工作要做,可以选择执行
设置
删除
OPTIONAL MATCH (c:Character)-[r1:IS_LOCATED_IN]->(l1:Location) where c.name=$char
WITH c
...
RETURN CASE
    WHEN c IS NULL THEN "Character not found"
    ELSE "something else
END AS message