简体   繁体   English

关系检索 Neo4j 的问题

[英]Problem with relationship retreival Neo4j

I have a deep relationship with multiple nodes.我与多个节点有很深的关系。 I want to create unique relationships between the items.我想在项目之间创建独特的关系。 I tried usage of IDs, but it did not help me a lot.我尝试使用 ID,但它对我没有多大帮助。 What is the best way to create unique relationship between node with intersection between other nodes?在节点与其他节点之间的交集之间创建唯一关系的最佳方法是什么?

This is a type of a relationship which I have https://imgur.com/a/YLUzXM3这是我拥有的一种关系https://imgur.com/a/YLUzXM3

MATCH r = (t)-[:HAS_FIELD]->(:Field {name: "Title"})-[:ON_LANGUAGE]->(:Language)-[:HAS_TRANSLATION]->(:Translation)

This is the code which I have to retrieve the relationship between the highest node (Green One) to the lowest (Gray one).这是我必须检索最高节点(绿色节点)与最低节点(灰色节点)之间关系的代码。

The biggest obstacle is that I want to retreive unique relationship between the node - One Green, One Purple, One Dark Green, and One Gray.最大的障碍是我想检索节点之间的独特关系 - 一个绿色,一个紫色,一个深绿色和一个灰色。 But instead of this, I receive all relationships, like you see on the screen.但不是这个,我收到所有关系,就像你在屏幕上看到的那样。

I found the way.我找到了方法。 I just simply add IDs of the topic to each relationship, so later on I will easy get the unique ones.我只是简单地将主题的 ID 添加到每个关系中,因此稍后我将轻松获取唯一的 ID。

(topic)-[:HAS_FIELD]->(f)-[:ON_LANGUAGE]->(l)-[:HAS_TRANSLATION {id: t.id}]->(tr)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM