I am new to Neo4j, have consulted documents but still confused. Could you help me?
Imagin that there are words, I link them by DERIVE relationship if possible.
w0 = etyma + suffix1 = etyma + suffix1
w1 = w0 + suffix2 = etyma + suffix1 + suffix2
w2 = w1 + suffix3 = etyma + suffix1 + suffix2 + suffix3
w3 = w2 + suffix4 = etyma + suffix1 + suffix2 + suffix3 + suffix4
w4 = prefix1 + w3 = prefix1 + etyma + suffix1 + suffix2 + suffix3 + suffix4
w5 = prefix2 + w4 = prefix2 + prefix1 + etyma + suffix1 + suffix2 + suffix3 + suffix4
CREATE (w0:Word{value:'w0'}) -[:DERIVE{value:'suffix2'}]-> (w1:Word{value:'w1'}) -[:DERIVE{value:'suffix3'}]-> (w2:Word{value:'w2'}) -[:DERIVE{value:'suffix4'}]-> (w3:Word{value:'w3'}) -[:DERIVE{value:'prefix1'}]-> (w4:Word{value:'w4'}) -[:DERIVE{value:'prefix2'}]-> (w5:Word{value:'w5'})
sometimes w6,w7,w8 exist.
w6 = prefix1 + w0 = prefix1 + etyma + suffix1
w7 = w6 + suffix2 = prefix1 + w1 = prefix1 + etyma + suffix1 + suffix2
w8 = w7 + suffix3 = prefix1 + etyma + suffix1 + suffix2 + suffix3
w4 = w8 + suffix4 = prefix1 + etyma + suffix1 + suffix2 + suffix3 + suffix4
MATCH (w0:Word{value:'w0'}) CREATE (w0) -[:DERIVE{value:'prefix1'}]-> (w6:Word{value:'w6'})
MATCH (w6:Word{value:'w6'}) CREATE (w6) -[:DERIVE{value:'suffix2'}]-> (w7:Word{value:'w7'})
MATCH (w7:Word{value:'w7'}) CREATE (w7) -[:DERIVE{value:'suffix3'}]-> (w8:Word{value:'w8'})
MATCH (w1:Word{value:'w1'}) MATCH (w7:Word{value:'w7'}) CREATE (w1) -[:DERIVE{value:'prefix1'}]-> (w7)
MATCH (w4:Word{value:'w4'}) MATCH (w8:Word{value:'w8'}) CREATE (w8) -[:DERIVE{value:'suffix4'}]-> (w4)
I want to find all derivatives by a word such as w0, then return w1,w2,w3,w4,w5,w6,w7,w8
get result below when I input MATCH p = (:Word{value:'w0'}) -[:DERIVE*1..]-> (:Word) RETURN nodes(p)
so how to program by cypher or with Spring Data Neo4j 7+ to get all nodes without duplicatiion