USE GRAPH financialGraph # create a query CREATE OR REPLACE QUERY q4 (datetime low, datetime high, LIST query_vector) SYNTAX v3 { MapAccum @@distances1; MapAccum @@distances2; // a path pattern in ascii art () -[]->()-[]->() c1 = SELECT b FROM (a:Account {name: "Scott"})-[e:transfer]->()-[e2:transfer]->(b:Account) WHERE e.date >= low AND e.date <= high and e.amount >500 and e2.amount>500; v = vectorSearch({Account.emb1}, query_vector, 2, {candidate_set: c1, distance_map: @@distances1}); PRINT v WITH VECTOR; PRINT @@distances1; // below we use variable length path. // *1.. means 1 to more steps of the edge type "transfer" // select the reachable end point and bind it to vertex alias "b" c2 = SELECT b FROM (a:Account {name: "Scott"})-[:transfer*1..]->(b:Account) WHERE a.name != b.name; v = vectorSearch({Account.emb1}, query_vector, 2, {candidate_set: c2, distance_map: @@distances2}); PRINT v WITH VECTOR; PRINT @@distances2; } #compile and install the query as a stored procedure install query q4 #run the query run query q4("2024-01-01", "2024-12-31", [-0.017733968794345856, -0.01019224338233471, -0.016571875661611557])