结合foreach和case来设置/删除关系属性 [英] combining foreach and case to set/remove relation properties

查看:182
本文介绍了结合foreach和case来设置/删除关系属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个集合,一个包含节点,另一个包含rels和节点(请参见 http:// console.neo4j.org/?id=ijoqaa

我试图实现的是更新rel属性,取决于一个节点是否在一个其他收藏品也存在。下面的代码演示了这个(希望),虽然它不是有效的密码。

  FOREACH(iterm in iterms | 
CASE
WHEN NOT(iterm [1] IN iaterms)THEN
REMOVE iterms [0] .pos,iterms [0] .neg
SET iterm [0] .explicit = 1
END

问题:在cypher中如何做到这一点?

解决方案

这是否行得通?

 <$ c (t)
不存在u - [:RELEVANCE] - >() - [:ISABOUT] - > $ b $ MATCH(u:user) - [i:INTEREST] b REMOVE i.neg,i.pos
SET i.explicit = 1


I have two collections, one containing nodes, and another containing rels and nodes (see http://console.neo4j.org/?id=ijoqaa)

What I try to achieve is to update the rel properties , depending on the whether a node in one collection is also present in the other. The code below illustrates this (hopefully), although it's not valid cypher.

FOREACH (iterm in iterms|
    CASE
        WHEN NOT (iterm[1] IN iaterms) THEN
            REMOVE iterms[0].pos,iterms[0].neg
            SET iterm[0].explicit=1
    END
)

Question: what is the way to do this in cypher ?

解决方案

Does this work?

MATCH (u:user)-[i:INTEREST]->(t)
WHERE NOT u-[:RELEVANCE]->()-[:ISABOUT]->t
REMOVE i.neg, i.pos
SET i.explicit = 1

这篇关于结合foreach和case来设置/删除关系属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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