Совпадение шифров Neo4j И против ИЛИ

#neo4j #cypher

#neo4j #шифр

Вопрос:

У меня есть следующий запрос на шифрование:

 MATCH (childD:Decision) MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]-gt;(mandatoryCriteriaId1:Criterion {deleted: false}) WHERE mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight gt;= 1.0 WITH childD  MATCH (childD)-[mandatoryCriteriaVote5:HAS_VOTE_ON]-gt;(mandatoryCriteriaId5:Criterion {deleted: false}) WHERE mandatoryCriteriaId5.id = 5 AND mandatoryCriteriaVote5.avgVotesWeight gt;= 3.0 WITH childD  RETURN childD  

Прямо сейчас следующая часть запроса:

 MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]-gt;(mandatoryCriteriaId1:Criterion {deleted: false}) WHERE mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight gt;= 1.0 WITH childD  MATCH (childD)-[mandatoryCriteriaVote5:HAS_VOTE_ON]-gt;(mandatoryCriteriaId5:Criterion {deleted: false}) WHERE mandatoryCriteriaId5.id = 5 AND mandatoryCriteriaVote5.avgVotesWeight gt;= 3.0 WITH childD   

работает как логическая операция AND . Это означает, что для возврата к результату запроса должны быть выполнены оба условия childD .

Как переписать этот запрос, чтобы он работал как логичный OR ?

Я имею в виду — вернуть все chilD , что соответствует любому из следующих условий:

 MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]-gt;(mandatoryCriteriaId1:Criterion {deleted: false}) WHERE mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight gt;= 1.0 WITH childD   

или

 MATCH (childD)-[mandatoryCriteriaVote5:HAS_VOTE_ON]-gt;(mandatoryCriteriaId5:Criterion {deleted: false}) WHERE mandatoryCriteriaId5.id = 5 AND mandatoryCriteriaVote5.avgVotesWeight gt;= 3.0 WITH childD   

Ответ №1:

Вы можете получить тот же результат, обновив свой, как показано ниже:

 MATCH (childD:Decision) MATCH (childD)-[mandatoryCriteriaVote1:HAS_VOTE_ON]-gt;(mandatoryCriteriaId1:Criterion {deleted: false})  WHERE (mandatoryCriteriaId1.id = 1 AND mandatoryCriteriaVote1.avgVotesWeight gt;= 1.0)  OR (mandatoryCriteriaId1.id = 5 AND mandatoryCriteriaVote1.avgVotesWeight gt;= 3.0)  RETURN childD