在v2.0.3中运行的查询
START n = NODE(67635)
MATCH (n:publication)
WHERE n.status <> 0
OPTIONAL MATCH (n)-[re:contains|can_use]->(e)
WHERE (e:article) AND (e.status <> 0 AND re.status <> 0)
WITH n, e
ORDER BY e.created DESC
WITH n, COLLECT(e) AS ce
RETURN n, ce[0..10], LENGTH(ce)
现在,在v2.1.2中,我得到以下错误:
Cannot match on a pattern containing only already bound identifiers (line 2, column 1)\n\"MATCH (n:publication)\"\n ^\n [exception] => SyntaxException\n [fullname] => org.neo4j.cypher.SyntaxException\n [stacktrace] => Array\n (\n [0] => org.neo4j.cypher.internal.compiler.v2_1.SemanticChecker$$anonfun$check$1.apply(SemanticChecker.scala:40)\n [1] => org.neo4j.cypher.internal.compiler.v2_1.SemanticChecker$$anonfun$check$1.apply(SemanticChecker.scala:40)\n
我知道如何修复它,但如果可能的话,我想避免在整个项目中修复查询。 还有其他解决办法吗?
答案 0 :(得分:1)
您可以将Neo4j数据库配置为使用较旧的Cypher编译器/解析器,例如: CYPHER 2.0
您可以针对每个查询执行此操作,也可以在neo4j.properties
cypher_parser_version=CYPHER 2.0
答案 1 :(得分:0)
将此重构为:
MATCH (n:publication)
WHERE ID(n)=67635 AND n.status <> 0
OPTIONAL MATCH (n)-[re:contains|can_use]->(e)
WHERE (e:article) AND (e.status <> 0 AND re.status <> 0)
WITH n, e
ORDER BY e.created DESC
WITH n, COLLECT(e) AS ce
RETURN n, ce[0..10], LENGTH(ce)
另请注意,匹配多种关系类型现在需要使用冒号作为每种类型的前缀:
old: OPTIONAL MATCH (n)-[re:contains|can_use]->(e)
new: OPTIONAL MATCH (n)-[re:contains|:can_use]->(e)