2017-02-22 11 views
0

次のcypherクエリでは、前のクエリの出力であるパラメータとして "cnt"を与えることによってパス長を制限する方法"with"句を使用して次のクエリに渡されます。このとき前のサブクエリの結果である可変長関係のパラメータとしてパス長を与えるCypherクエリ

match()-[r:contents|next_seq]->(n:word) where r.seqid={seqid} with count(distinct n) as cnt match p=((a:word)-[rels:next_seq*cnt]->(b:word)) WHERE ALL(rt in rels WHERE rt.seqid={seqid} return b.name

答えて

2

cypherは経路長として変数を使用することはできません。あなたがneo4jのバージョンを使用する場合

> = 3を使用できapoc path expander

match()-[r:contents|next_seq]->(n:word) where r.seqid={seqid} 
with count(distinct n) as cnt 
match (a:word)-[rels:next_seq {seqid: {seqid}}]->(:word)) 
with distinct a 
call apoc.path.expand(a, 'next_seq', '+word', 1, cnt) yield path 
with path WHERE ALL(rt in relationships(path) where rt.seqid={seqid}) 
return last(nodes(path)).name as name 
関連する問題