graphaware / neo4j-uuid

GraphAware Runtime Module that assigns a UUID to all nodes (and relationships) in the graph transparently
103 stars 22 forks source link

Slicing by uuid #25

Closed ghost closed 8 years ago

ghost commented 8 years ago

Given that I have a list of nodes, in this case retrieved from ga.timetree.events.range(start, end) and ordered in descending order based on the timestamp, is it possible to slice that list using a WHERE clause and a comparison operator to retrieve all the nodes after a specific uuid?

crude ex: posts = [ ({uuid: "1sdasda"}), ({uuid: "232erads"}), ({uuid: "asdas3"}), ({uuid: "4asdas"}) ]

WITH posts WHERE posts.uuid > "232erads"

expecting: posts = [ ({uuid: "asdas3"}), ({uuid: "4asdas"}) ]

I tried it with the neo4j explorer and the results were a bit inconsistent so I wanted to see if it's officially possible or not. If not, are there any recommended paths to a solution?

ikwattro commented 8 years ago

I tried the following and the results are as expected :

neo4j-sh (?)$ MATCH (n) DETACH DELETE n;
+-------------------+
| No data returned. |
+-------------------+
Nodes deleted: 4
30 ms
neo4j-sh (?)$ WITH ["1sdasda","232erads","asdas3","4asdas"] as uuids
> UNWIND uuids as uuid
> CREATE (n:Node {uuid: uuid});
+-------------------+
| No data returned. |
+-------------------+
Nodes created: 4
Properties set: 4
Labels added: 4
16 ms
neo4j-sh (?)$ MATCH (n:Node) WHERE n.uuid > "232erads" RETURN n;
+---------------------------+
| n                         |
+---------------------------+
| Node[8198]{uuid:"asdas3"} |
| Node[8199]{uuid:"4asdas"} |
+---------------------------+
2 rows
24 ms
neo4j-sh (?)$

What have you tried exactly and what do you mean by inconsistent ?

ghost commented 8 years ago

My mistake, I was ordering in descending order by a timestamp and selecting the topmost uuid to slice with, expecting to receive 0 rows. In another test I ordered by UUID and it performed as expected.

Would probably be helpful to others if this capability was added to your Cypher docs.

Thank you for the example btw!

ikwattro commented 8 years ago

How to use ORDER BY is part of the Neo4j Cypher documentation