Prabjot Singh
Prabjot Singh

Reputation: 4767

Neo4j duplicate records issue

I am facing issues of duplicate recoreds on simple query. In my database, i have some countries data and countries points to organization types. I am fetching countries and organizations, database giving me duplicate records in both country and organization types.

Query

MATCH (n:OrganizationType),(c:Country) RETURN n,c LIMIT 25

Tried also with distinct

MATCH (n:OrganizationType),(c:Country) RETURN distinct n,c LIMIT 25

Graphical view of records

enter image description here

Please help me what i am missing here ?

Upvotes: 1

Views: 197

Answers (1)

Tore Eschliman
Tore Eschliman

Reputation: 2507

Your query is returning pairs of (organization, country), and when you put DISTINCT on it, it just ensures that the pair is distinct. When building queries, don't think of "returning records", but of "generating result rows". If you want to generate result rows that contain 1 node, which is either a Country or an Organization, and you want every Country or Organization to get 1 row, up to 25 total rows, try a simple query like this:

MATCH (n)
WHERE n:Country OR n:Organization
RETURN n LIMIT 25

Upvotes: 1

Related Questions