GKyle
GKyle

Reputation: 679

Find Nodes with the same properties in Neo4J

I have two datasets in Neo4J. I would like to find all nodes within these two datasets that have the same particular property. This is using Cypher code.

I am currently using:

MATCH n=node(*), m=node(*)
WHERE (n.name) AND (m.name) AND 
  n.name=m.name 
RETURN n, m

In the hope to get a result showing all nodes with the same name.

I am aware of this old 2013 post here: neo4j find all nodes with matching properties

But the Cypher code has been significantly updated since this date.

Any help would be great thanks.

Upvotes: 4

Views: 7867

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41676

There are no tables in Neo4j

create index on :LabelA(propertyA);
create index on :LabelB(propertyB);

MATCH (a:LabelA)
MATCH (b:LabelB)
WHERE b.propertyB = a.propertyA
RETURN a,b;

Upvotes: 7

Related Questions