在Neo4j 1.9中删除旧的节点和与Cypher的关系 [英] Delete old nodes and relationships with Cypher in Neo4j 1.9

查看:121
本文介绍了在Neo4j 1.9中删除旧的节点和与Cypher的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在HA模式下使用Neo4j 1.9 M03,我面临的挑战是删除所有早于特定日期的节点和关系以及索引.

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.

为此,我为节点和关系创建了一个属性.该属性是"YYMMDD"格式的日期戳.

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

我正在尝试使用以下Cypher查询来执行上述操作:

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?

推荐答案

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;

这篇关于在Neo4j 1.9中删除旧的节点和与Cypher的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆