0

Cypher で次のクエリの出力を理解しようとしています。

start n=node:node_auto_index(name="root_node")
match n-[:SC]->c, b<-[:CB]-c-[:CB]->b1
where (b.days_in_number - b1.days_in_number <= 7) AND (b.days_in_number > b1.days_in_number)
and c.name = "C16659"
with  distinct n,c, b, b1
match  n-[:SC]->c-[:CB]->b-[:CT]->i1, n-[:SC]->c-[:CB]->b1-[:CT]->i2 
with b.name as bname,b1.name as b1name,i1.name as i1name,i2.name as i2name
return  bname,b1name,i1name,i2name
order by bname,b1name,i1name,i2name;

3680 行を返します

start n=node:node_auto_index(name="root_node") 
match n-[:SC]->c, b<-[:CB]-c-[:CB]->b1
where (b.days_in_number - b1.days_in_number <= 7) AND (b.days_in_number > b1.days_in_number)
and c.name = "C16659"
with  distinct n,c, b, b1
match  b-[:CT]->i1, b1-[:CT]->i2 
with b.name as bname,b1.name as b1name,i1.name as i1name,i2.name as i2name
return  bname,b1name,i1name,i2name
order by bname,b1name,i1name,i2name;

184行を返します

クエリ 1 はデカルトを行っているようですが、その理由がわかりません。誰でも説明できますか?

c-[:CB]->b は 1:n の関係です。

アップデート:

次のクエリを実行すると、正しい 184 の結果が得られます。

start n=node:node_auto_index(name="root_node") 
match n-[:SC]->c, b<-[:CB]-c-[:CB]->b1
where (b.days_in_number - b1.days_in_number <= 7) AND (b.days_in_number > b1.days_in_number)
and c.name = "C16659"
with  distinct n,c, b, b1
match  c-[:CB]->b-[:CT]->i1, c-[:CB]->b1-[:CT]->i2 
with n.name as nname,c.name as cname, b.name as bname,b1.name as b1name,i1.name as i1name,i2.name as i2name
return  nname,cname,bname,b1name,i1name,i2name
order by nname,cname,bname,b1name,i1name,i2name;

これは、 n を元に戻すとデカルトにつながることを示唆しています。

n-[:SC]->c は 1:1 の関係です。なぜこうなった?

4

1 に答える 1

0

n と c の関係が本当に一意であることを確認しましたか? パスを見ると役立つかもしれません。試す

match p1=n-[:SC]->c-[:CB]->b-[:CT]->i1, p2=n-[:SC]->c-[:CB]->b1-[:CT]->i2
return p1,p2

追加の結果が互いに異なる場所を確認します。

于 2013-04-09T06:50:29.667 に答える