문제

I am using Neo4j 1.9 M03 in HA mode, my challenge is to remove all nodes and relationships as well as indices that are older than a certain date.

For this I created a property for nodes and relationships. The property is a datestamp in the "YYMMDD" format.

I'm trying to use the following Cypher query to perform the operation mentioned above:

START n0=node(0), nx=node(*) 
MATCH n0-[r0?]-(), nx-[rx?]-() 
WHERE nx <> n0 AND HAS (nx.datestamp) AND nx.datestamp <= yyyymmdd 
OR HAS (rx.datestamp) AND rx.datestamp <= yyyymmdd
DELETE r0,rx,nx

This query is not performing the operation I desire. What can I be doing wrong here?

도움이 되었습니까?

해결책 2

START rx=rel(*)
WHERE HAS (rx.datestamp) AND rx.datestamp <= yyyymmdd
DELETE rx;

You have to make sure that the nodes you want to delete don't have any relationships left, either filter those out or you delete those additionally

START nx=node(*)
WHERE HAS (nx.datestamp) AND nx.datestamp <= yyyymmdd
AND NOT((nx)--())
DELETE nx;

다른 팁

You can try this one

START n=node(*) 
MATCH n-[r?]-() 
WHERE  (n.datestamp? <= yyyymmdd AND r.datestamp? <= yyyymmdd) 
DELETE r,n
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top