【发布时间】:2021-12-04 12:24:43
【问题描述】:
我有以下 Cypher 查询:
MATCH (childD:Decision)
MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]->(mandatoryCriteriaId1:Criterion {deleted: false}) WHERE mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight >= 1.0 WITH childD
MATCH (childD)-[mandatoryCriteriaVote5:HAS_VOTE_ON]->(mandatoryCriteriaId5:Criterion {deleted: false}) WHERE mandatoryCriteriaId5.id = 5 AND mandatoryCriteriaVote5.avgVotesWeight >= 3.0 WITH childD
RETURN childD
现在是查询的以下部分:
MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]->(mandatoryCriteriaId1:Criterion {deleted: false}) WHERE mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight >= 1.0 WITH childD
MATCH (childD)-[mandatoryCriteriaVote5:HAS_VOTE_ON]->(mandatoryCriteriaId5:Criterion {deleted: false}) WHERE mandatoryCriteriaId5.id = 5 AND mandatoryCriteriaVote5.avgVotesWeight >= 3.0 WITH childD
用作逻辑操作AND。这意味着childD 必须同时满足这两个条件才能返回查询结果。
如何重写此查询以便像逻辑 OR 一样工作?
我的意思是 - 返回所有满足以下任一条件的chilD:
MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]->(mandatoryCriteriaId1:Criterion {deleted: false}) WHERE mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight >= 1.0 WITH childD
或
MATCH (childD)-[mandatoryCriteriaVote5:HAS_VOTE_ON]->(mandatoryCriteriaId5:Criterion {deleted: false}) WHERE mandatoryCriteriaId5.id = 5 AND mandatoryCriteriaVote5.avgVotesWeight >= 3.0 WITH childD
【问题讨论】: