cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

Create relationship

iganea9
Node Link

I'm defining the relationship between two entities, Variety and Treatment.
match (s1:Variety),(c:Treatment)
where id(s1)=0 and id(c)=4
create (s1) - [rel:UNTREATED]-> (c)
return type(rel)
Result is '(no changes, no records)'.
In this context, an error occurs:
This query builds a cartesian product between disconnected patterns.

4 REPLIES 4

glilienfield
Ninja
Ninja

It worked for me. Are you sure the two nodes exist.

You can refactor the code as follows to eliminate the warning and to ensure the relationship doesn't get recreated every time you run the query:

match (s1:Variety) where id(s1)=0
match (c:Treatment) where id(c)=1
merge (s1) - [rel:UNTREATED]-> (c)
return type(rel)

Note: the id's are from my test data. Change appropriately.

Thanks. But the result is the same. The nodes exists.
3X_3_1_31ccb30be34628a27efbaa8fcee44451c8491cbc.png

Previously this was working. Current version Neo4j is 1.4.12.

You screenshot shows your label is "Varieties", not "Variety." There is also no label "Treatment." Could this explain it?

koji
Ninja
Ninja

Hi @iganea9

Here is my environment.

macOS 12.2
Neo4j Desktop 1.4.12
Neo4j 4.4.3

I created the 5 nodes.

CREATE (:Variety);   // id()=0
CREATE (:Label1);    // id()=1
CREATE (:Label2);    // id()=2
CREATE (:Label3);    // id()=3
CREATE (:Treatment); // id()=4

Your Cypher works correctly.
I ran it 3 times.

MATCH (s1:Variety),(c:Treatment)
  WHERE id(s1)=0 AND id(c)=4
CREATE (s1)-[rel:UNTREATED]->(c)
RETURN type(rel)

You may be able to find the problem with this Cypher.

MATCH (n)
  WHERE id(n) IN [0,4]
RETURN n;