I am using Nebula Graph database and trying to write a query that stops the chain when encountering a specific node and ignores any relationships beyond that node. For example, I have the following graph structure:
a -> b -> c -> d -> e
I want to start the query from node a and follow the chain, but if the query encounters node c, it should stop and not include the relationships from c to d and from d to e.
Here is the setup for the vertices and edges:
USE ethereum;
-- Create addresses
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':();
-- Establish relationships
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");
I have tried the following query to achieve this, but it still includes the relationship from d to e:
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
The result includes:
[: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"}]
How can I modify the query to ensure that the chain is interrupted at node c and any relationships beyond c are ignored?
Thank you for your help!