"$domain = GO 1 STEPS " \
"FROM '159.138.142.152' OVER * REVERSELY " \
"WHERE properties($$).name IS NOT EMPTY and labels($$)[0] == 'domain' " \
"YIELD id($$) AS url;" \
"$data = GO 2 STEPS FROM $domain.url OVER * " \
"WHERE properties($$).name IS NOT EMPTY and labels($$)[0] IN ['victim_card', 'victim_phone', 'victim_bank', 'victim_address', 'browser_id'] " \
"YIELD properties($$).name as victim_data, $$.browser_id.name as suspect_data; " \
"YIELD $domain.url as url, count($data.suspect_data) as suspect_numbers, count(*)-count($data.suspect_data) as victim_numbers;"
"$domain = GO 1 STEPS " \
"FROM '159.138.142.152' OVER * REVERSELY " \
"WHERE properties($$).name IS NOT EMPTY and labels($$)[0] == 'domain' " \
"YIELD id($$) AS url;" \
"$data = GO 2 STEPS FROM $domain.url OVER * " \
"WHERE properties($$).name IS NOT EMPTY and labels($$)[0] IN ['victim_card', 'victim_phone', 'victim_bank', 'victim_address', 'browser_id'] " \
"YIELD $domain.url as url, properties($$).name as victim_data, $$.browser_id.name as suspect_data; " \
"YIELD $data.url as url, count($data.suspect_data) as suspect_numbers, count(*)-count($data.suspect_data) as victim_numbers;"
Cypher 语法或许可以更自然的表达你的需求
MATCH (a)<--(b:domain)-[*2]->(c) where id(a)=='159.138.142.152'
WITH a,b,c where labels(c)[0] in ['victim_card', 'victim_phone', 'victim_bank', 'victim_address', 'browser_id']
RETURN id(b), count(*)-count(CASE WHEN labels(c)[0]=='browser_id' THEN true ELSE null END) AS victim_numbers
GO FROM "player101" OVER follow REVERSELY
YIELD src(edge) AS id |
GO FROM $-.id OVER serve
WHERE properties($$).name IS NOT EMPTY and properties($$).name in ['Raptors', 'Spurs']
YIELD properties($^).name AS FriendOf | YIELD $-.FriendOf as name, count(*) AS Team;