Reputation: 71
Hi I am learning Neo4j Database, I had an issue with one of the query as it seems to be not returning a valid output. Here is my complete dataset
Query that giving issue is MATCH (usr:USER)-[:KNOWS]->(lang:SKILL) where lang.name="Python" AND lang.name="FastAPI" return usr
,
Expected Output is Vibhav
Node. But instead its not returning any value
Please help me to understand this. Thanks in Advance!!
Upvotes: 0
Views: 46
Reputation: 793
From the visualization we can see that some urs have more than one lang skill. So, you could use OR logic and count the returns:
MATCH (usr:USER)-[r:KNOWS]->(lang:SKILL) where lang.name="Python" OR lang2.name="FastAPI" with urs, count(*) as ct with usr where ct=2 return usr
This might run faster that Tomaz's suggestion ... you'll have to test it.This assumes you will not have duplicate edges to a skill node.
Upvotes: 1
Reputation: 6514
You are setting two predicates on the same node, which will not work as a single node cannot have two names. What you need to do is:
MATCH (lang2:SKILL)<-[:KNOWS]-(usr:USER)-[:KNOWS]->(lang:SKILL)
where lang.name="Python" AND lang2.name="FastAPI"
return usr
Upvotes: 2