I try to find a right queries, at moment from the browser. I have a simple graph with node dependencies like parent -[:depend]-> child, each node have a modification_date attribute. From the last child I want to return all the "younger" parent in relation to their direct children, it's a real headache for me =].
Here a simple schema:
At the moment I can't think of a good query to use that would evaluate dynamically during traversal, but here's a query that will filter afterwards:
MATCH path = (AC:Node {name:10})<-[:DEPEND*..4]-(A:Node)
WITH A, [node in nodes(path) | node.modif_date] as dates
WHERE all(i in range(0, size(dates) - 2) WHERE dates[i] < dates[i + 1])
RETURN A
This one is a bit tricky, we need to use a nested pattern comprehension within the list comprehension (and make sure to project out the first element from that pattern comprehension):
MATCH path = (AC:Node {name:10})<-[:DEPEND*..4]-(A:Node)
WITH A, [node in nodes(path) | [(node)-[r:CURRENT]->() | r.modification_date][0]] as dates
WHERE all(i in range(0, size(dates) - 2) WHERE dates[i] < dates[i + 1])
RETURN A
Thanks a lot, Cypher is very powerful ! However my real case is still a bit tricky because r.modification_date is not always present ... Therefore I have some null values in dates lists : [null, 1544706574.1611595, null, 1543230042.1031768]. I tried to filter like that in the nested list but I still have those null :
[(node)-[r:CURRENT]->() where not r.modification_date is null | r.modification_date]
My mistake, I confused this question with a different one. You aren't using APOC Procedures here, it's not relevant to your question. Please disregard the request for the APOC version.
You may want to try upgrading your version, I know there was a bug affecting the planning of nested pattern comprehensions in 3.4.5 and below. Try upgrading to 3.4.10 (or 3.4.11) and see if you get expected results.
Hi again @andrew_bowman.
I upgraded neo4j 3.5.1, but unfortunately I still those null values.... what is weird that is : [node in nodes(path) | [(node)-[r:CURRENT]->() where r.modification_date is null | r.modification_date][0]]
give me null only, which mean not is the problem... ?