我正在使用 Nebula Graph 数据库,并尝试编写一个查询,使其在遇到特定节点时中断查询链条,并忽略该节点之后的所有关系。举个例子,我有以下图结构:
```
a -> b -> c -> d -> e
```
我想从节点 a 开始查询,沿着链条进行,但如果查询遇到节点 c ,应该停止查询,并且不包括 c 到 d 和 d 到 e 的关系。
以下是我的顶点和边的设置:
```
USE ethereum;
-- 创建地址
INSERT VERTEX IF NOT EXISTS address() VALUES 'a':();
INSERT VERTEX IF NOT EXISTS address() VALUES 'b':();
INSERT VERTEX IF NOT EXISTS address() VALUES 'c':();
INSERT VERTEX IF NOT EXISTS address() VALUES 'd':();
INSERT VERTEX IF NOT EXISTS address() VALUES 'e':();
-- 建立关系
INSERT EDGE erc20_transfer_to (transfer_timestamp, block_no, tx_hash, symbol) VALUES
"a" -> "b":(1622548800, 1234567, "0x123abc", "ETH");
INSERT EDGE erc20_transfer_to (transfer_timestamp, block_no, tx_hash, symbol) VALUES
"b" -> "c":(1622549800, 1234568, "0x456def", "ETH");
INSERT EDGE erc20_transfer_to (transfer_timestamp, block_no, tx_hash, symbol) VALUES
"c" -> "d":(1622550800, 1234569, "0x789ghi", "ETH");
INSERT EDGE erc20_transfer_to (transfer_timestamp, block_no, tx_hash, symbol) VALUES
"d" -> "e":(1622551800, 1234570, "0xabcjkl", "ETH");
```
我尝试了以下查询:
```
GO 1 TO 5 STEPS FROM "a"
OVER erc20_transfer_to
WHERE dst(edge) != "c"
YIELD src(edge) AS src, dst(edge) AS dst, edge AS e
```
但是结果仍然包括从 d 到 e 的关系:
```
[:erc20_transfer_to "a"->"b" @0 {block_no: 1234567, symbol: "ETH", transfer_timestamp: 1622548800, tx_hash: "0x123abc"}]
[:erc20_transfer_to "d"->"e" @0 {block_no: 1234570, symbol: "ETH", transfer_timestamp: 1622551800, tx_hash: "0xabcjkl"}]
[:erc20_transfer_to "c"->"d" @0 {block_no: 1234569, symbol: "ETH", transfer_timestamp: 1622550800, tx_hash: "0x789ghi"}]
```
请问如何修改查询,确保在遇到节点 c 时中断链条,并忽略 c 之后的所有关系?
谢谢大家的帮助! |
|