Domanda

I am using last.fm dataset and imported it in neo4j 2.0.1. Now i want to traverse the graph so that I can get similar result which, I am getting by executing following MySQL query:

SELECT * from music.logs, music.features, music.nodespart2
WHERE logs.song="1000001" 
    AND logs.song=features.scrobble 
    AND fetures.mbid=nodespart2.name;

In neo4j I want to execute similar query, starting from a particular index lets say 1000001->logs->features... Any help would be appreciated.

È stato utile?

Soluzione

I am not pretty sure about the graph model yet and what propertiess are you storing in the nodes and on relationship. But from the links you shared I think below query should work..

 MATCH (a)-[:LOGS]->(b)-[:FEATURES]->(c) where a.type="listener" 
 and b.type="scrobble"
 and c.type="track" and b.name = "100001" return *

This will give all listeners and tracks related to a particular scrobble with name 1000001

EDIT after comment

 MATCH (b)-[:FEATURES]->(c) where b.type="scrobble" and c.type="track" 
 and b.name = "100001" return c.title

I would recommend to reimport your dataset with Labels. More info on labels: here. It will save the effort of checking type again and again and will enable you to incorporate it in the match pattern itself; also its more efficient.

EDIT after labels were added

Query1:

MATCH (a:listener)-[:LOGS]->(b:scrobble)-[:FEATURES]->(c:track) 
where b.name = "100001" return *

Query2:

MATCH (b:scrobble)-[:FEATURES]->(c:track) where b.name = "100001" return c.title
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top