0
私は人が送信したSMSテキストメッセージを表します。問題を簡略化するために、私は2つのノード(1人の人、1人の電話)と3人の関係(人は電話を持っていて、自分自身に2つのテキストメッセージを送りました)を持っています。私は、次のサイファークエリを実行する場合サイファークエリが機能しない
try (Transaction tx = graphDb.beginTx())
{
Node aNode1 = graphDb.createNode();
aNode1.addLabel(DynamicLabel.label("Person"));
aNode1.setProperty("Name", "Juana");
tx.success();
Node aNode2 = graphDb.createNode();
aNode2.addLabel(DynamicLabel.label("Phone"));
aNode2.setProperty("Number", "1111-1111");
tx.success();
// (:Person) -[:has]->(:Phone)
aNode1.createRelationshipTo(aNode2, RelationshipType.withName("has"));
tx.success();
// finally SMS text sent at different moments
// (:Phone) -[:sms]-> (:Phone)
Relationship rel1 = aNode2.createRelationshipTo(aNode2, RelationshipType.withName("sms"));
rel1.setProperty("Length", 100);
tx.success();
Relationship rel2 = aNode2.createRelationshipTo(aNode2, RelationshipType.withName("sms"));
rel2.setProperty("Length", 50);
tx.success();
}
は:
MATCH (p1 :Person)-[:has]-> (n1 :Phone) -[r :sms]-(n2: Phone)<-[:has]-(p2 :Person)
RETURN p1, p2
Iはゼロタプルを得、次のようにグラフが作成されました。私はp1とp2(この場合は同じ人物)の間にテキストをsmsしなければならないので、結果セットを理解していません。私は、クエリ内のノードP2を排除した場合
驚くべきことに、:
MATCH (p1 :Person)-[:has]-> (n1 :Phone) -[r :sms]-(n2: Phone)
RETURN p1
私はフアナ、予想通り得ます。
私の最初のクエリの結果セット(ゼロタプル)は理解できません。