Skip a partical node while showing connection in graph view.

huangapple go评论71阅读模式
英文:

Skip a partical node while showing connection in graph view

问题

在图形数据库(Neo4j)中,我需要维护基于微服务架构的所有现有资源的库存。为此,我必须创建两个视图,一个顶层视图和一个详细视图。

考虑这是我的关系:

节点(lambdaXYZ) -[r:API_CALL]- 节点(NatGatewayABC) -[r:API_CALL]- 节点(ec2ABC)

但我想要两种不同类型的视图:

  1. 第一个是上述视图类型
    lambdaXYZ -> NatGatewayABC -> ec2ABC

  2. 第二个是摘要视图,类似于这样
    lambdaXYZ -> ec2ABC

基本上我想跳过一些节点,只显示一个预览。
这是因为我需要在数据库中保留NatGateway以存储IP地址等信息。

如何实现这个目标?

英文:

In a graph DB (Neo4j), I need to maintain inventory of all the existing resources in a microservices-based architecture. For this I have to create 2 views, a top level view and a detailed view.

Consider this is my relationship:

Node(lambdaXYZ) -[r:API_CALL]- Node(NatGatewayABC) -[r:API_CALL]- Node(ec2ABC)

but I want 2 different types of views:

  1. the first is the above view type
    lambdaXYZ -> NatGatewayABC -> ec2ABC

  2. second is a summary view which is something like this
    lambdaXYZ -> ec2ABC

Basically I want to skip some nodes and show only a preview.
This is because I need to have NatGateway in the database to store the IP address from etc.

How to achieve this?

答案1

得分: 0

It looks like you want to create a virtual relationship to represent a "summary" path (going from the first Node to the last Node in some actual path).

For example, here is how you can create a SUMMARY-CALL virtual relationship between the lambdaXYZ Node and the last Node in any chain of outgoing API_CALL relationships (up to length 7):

MATCH (n1:Node)-[:API_CALL*..7]->(n2:Node)
WHERE n1.id = 'lambdaXYZ' AND NOT EXISTS((n2)-[:API_CALL]->())
RETURN n1, n2, apoc.create.vRelationship(n1,'SUMMARY_CALL',{}, n2)

英文:

It looks like you want to create a virtual relationship to represent a "summary" path (going from from the first Node to the last Node in some actual path).

For example, here is how you can create a SUMMARY-CALL virtual relationship between the lambdaXYZ Node and the last Node in any chain of outgoing API_CALL relationships (up to length 7):

MATCH (n1:Node)-[:API_CALL*..7]->(n2:Node)
WHERE n1.id = 'lambdaXYZ' AND NOT EXISTS((n2)-[:API_CALL]->())
RETURN n1, n2, apoc.create.vRelationship(n1,'SUMMARY_CALL',{}, n2)

huangapple
  • 本文由 发表于 2023年5月14日 16:39:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76246574.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定