cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

MATCH with multiple labels seems to return wrong results

Neo4j version: 4.2.5
Java Driver version: 4.1.1 & 4.2.4

See attached screenshot. The following query returns a node with a wrong label:

MATCH (n:NodeInterface:YWRYQFALBS:SchemaNode:NodeInterface) WHERE n.`name` = "Group" RETURN DISTINCT n

I was not able to reproduce the issue with a simple set of statemets. It occurs randomly during our integration test suite when different test threads execute multiple statements with random identifiers (NCRLAOJOUF and YWRYQFALBS in this case).

Do you see anything that could possibly be changed to fix the query? It looks like a bug, but without a simple reproduction. Should I open an issue on github?

Thank you!

2 REPLIES 2

Hello,

I have few questions:

  1. Why are you using same label twice i.e. NodeInterface in the MATCH clause?
  2. The selection condition in the WHERE clause is used to filter the result set based on the condition that name associated with the node is group. al though the highlighted node doesnot seem to have a node property 'name'.

Based on the available information i have a solution. I have considered the following database structure:
Create (h1:HUMAN{gender:"Male", age:"43"})-[o:OWNS{since:"2021"}]->(p1:PROPERTY{type:"Building", constructedOn:"03-02-2020"}),
(h2:HUMAN{gender:"Female", age:"33",name:"Mini"})-[o1:OWNS]->(a1:ANIMAL{type:"Dog", name:"Goofy"}),
(h1)-[:KNOWS]->(h2)-[:KNOWS]->(h1)

The query which works to what you wish to extract.
Match (a)
Unwind labels(a) as nodelabels
With nodelabels as nodelabels, a as a
Where nodelabels = 'HUMAN' OR nodelabels = 'PROPERTY'
Return a

In the query i am filtering based on the node labels and i am assuming that each node has only one node label associated with it. However, the query can be modified in the WHERE clause to support the searching for multiple node labels.