Search code examples
cyphermemgraphdb

Problem with tree time and Cypher query in Memgraph


I have created a time tree in Memgraph, I ran the queries individually, and I am getting the correct result. But if I run them together as part of the same query, I get a null set. Why is that so?

memgraph> MATCH (y:YEAR {year:2015})-[:HAS_MONTH]->(m:MONTH {month:1})-[:HAS_DAY]->(d:DAY {day:22})-[:HAS_HOUR]->(h:HOUR {hour:6})-[:HAS_MINUTE]->(min2: MINUTE {minute: 50})
       -> RETURN min2;
+----------------------------------------------------+
| min2                                               |
+----------------------------------------------------+
| (:MINUTE {day: 22, hour: 6, minute: 50, month: 1}) |
+----------------------------------------------------+
1 row in set (0.000 sec)
memgraph> MATCH (y:YEAR {year:2015})-[:HAS_MONTH]->(m:MONTH {month:1})-[:HAS_DAY]->(d:DAY {day:22})-[:HAS_HOUR]->(h:HOUR {hour:7})-[:HAS_MINUTE]->(min2: MINUTE {minute: 0})
       -> RETURN min2;
+---------------------------------------------------+
| min2                                              |
+---------------------------------------------------+
| (:MINUTE {day: 22, hour: 7, minute: 0, month: 1}) |
+---------------------------------------------------+
1 row in set (0.001 sec)
memgraph> MATCH (y:YEAR {year:2015})-[:HAS_MONTH]->(m:MONTH {month:1})-[:HAS_DAY]->(d:DAY {day:22})-[:HAS_HOUR]->(h:HOUR {hour:7})-[:HAS_MINUTE]->(min2: MINUTE {minute: 0})
       -> MATCH (y:YEAR {year:2015})-[:HAS_MONTH]->(m:MONTH {month:1})-[:HAS_DAY]->(d:DAY {day:22})-[:HAS_HOUR]->(h:HOUR {hour:6})-[:HAS_MINUTE]->(min1: MINUTE {minute: 50})
       -> RETURN min1, min2;
Empty set (0.000 sec)

Solution

  • If you want to get the same year, month, day and hour, and two different minutes the code would be:

    memgraph> MATCH (y:YEAR {year:2015})-[:HAS_MONTH]->(m:MONTH {month:1})-[:HAS_DAY]->(d:DAY {day:22})-[:HAS_HOUR]->(h:HOUR {hour:7})-[:HAS_MINUTE]->(min:MINUTE)
           -> WHERE min.minute = 0 OR min.minute = 50
           -> RETURN min;