Newbie''s query fails to show Node properties.

9 views
Skip to first unread message

leam hall

unread,
Aug 9, 2016, 6:57:32 AM8/9/16
to Neo4j
Newbie question. With the two datasets below, the following query gives me a graph but the nodes have no data in them besides the id number:

  MATCH (n)-[:FRIEND]-(p) RETURN n,p;

While this gives no rows:

  MATCH (n:Person)-[:FRIEND]-(p) RETURN n,p;

What I'm trying to do is list all the nodes and their relationships. Using the temporary cloud based Neo4J instance. 

Recommendations?

Thanks!

Leam

#####

The Person dataset:
CREATE (JaniceH:Person {name:"Janice Howell", upp:"A99EAD", gender:"F", dob:"1392", career:"Socialite", work:"HowellIndustries", faction:"Janice"})
CREATE (MagdelanaP:Person {name:"Magdelana Patterson", upp:"789CAB", gender:"F", dob:"1389", career:"Noble", work:"AgriBusiness", faction:"Janice"})
CREATE (MarciM:Person {name:"Marci Monroe", upp:"993A7B", gender:"F", dob:"1392", career:"Artist", work:"BiterCrimeDaughter", faction:"Janice"})
CREATE (JaredW:Person {name:"Jared Wilkins", upp:"495DCE", gender:"M", dob:"1389", career:"Noble", work:"ScientistPharma", faction:"Janice"})
CREATE (DonaW:Person {name:"Dona Wilkins", upp:"777777", gender:"F", dob:"1384", career:"Psion", work:"Sanctuary", faction:"Sanctuary"})
CREATE (MarcoD:Person {name:"Marco Domici", upp:"78A89B", gender:"M", dob:"1386", career:"Marine/Noble", work:"Theocracy", faction:"Theocracy"})
CREATE (IreneP:Person {name:"Irene Pace", upp:"BAB749", gender:"F", dob:"1387", career:"Marine/Noble", work:"Theocracy", faction:"Theocracy"})

The Relationship dataset:

CREATE (MarcoD)-[:MARRIED_TO]->(IreneP)
CREATE (IreneP)-[:MARRIED_TO]->(MarcoD)
CREATE (JaniceH)-[:LOVER]->(GothanD)
CREATE (GothanD)-[:LOVER]->(JaniceH)
CREATE (MagdelanaP)-[:FRIEND]->(MarcoD)
CREATE (MarcoD)-[:FRIEND]->(MagdelanaP)
CREATE (JaniceH)-[:FRIEND]->(MagdelanaP)
CREATE (MagdelanaP)-[:FRIEND]->(JaniceH)
CREATE (GothanD)-[:FRIEND]->(MarcoD)
CREATE (MarcoD)-[:FRIEND]->(GothanD)

Michael Hunger

unread,
Aug 9, 2016, 7:00:23 AM8/9/16
to ne...@googlegroups.com
Leam,

did you run that whole statement in one go or in two parts?

If you run it in two parts the "variable names" from the first query are no longer bound (as you run a new query). So it creates new nodes for those,e .g. `MarcoD`.

If you run the whole statement in one go, the variables will still have the nodes that you created bound to them.

// cleanup
match (n) detach delete n;

// create nodes AND relationships
CREATE (JaniceH:Person {name:"Janice Howell", upp:"A99EAD", gender:"F", dob:"1392", career:"Socialite", work:"HowellIndustries", faction:"Janice"})
CREATE (MagdelanaP:Person {name:"Magdelana Patterson", upp:"789CAB", gender:"F", dob:"1389", career:"Noble", work:"AgriBusiness", faction:"Janice"})
CREATE (MarciM:Person {name:"Marci Monroe", upp:"993A7B", gender:"F", dob:"1392", career:"Artist", work:"BiterCrimeDaughter", faction:"Janice"})
CREATE (JaredW:Person {name:"Jared Wilkins", upp:"495DCE", gender:"M", dob:"1389", career:"Noble", work:"ScientistPharma", faction:"Janice"})
CREATE (DonaW:Person {name:"Dona Wilkins", upp:"777777", gender:"F", dob:"1384", career:"Psion", work:"Sanctuary", faction:"Sanctuary"})
CREATE (MarcoD:Person {name:"Marco Domici", upp:"78A89B", gender:"M", dob:"1386", career:"Marine/Noble", work:"Theocracy", faction:"Theocracy"})
CREATE (IreneP:Person {name:"Irene Pace", upp:"BAB749", gender:"F", dob:"1387", career:"Marine/Noble", work:"Theocracy", faction:"Theocracy"})
CREATE (MarcoD)-[:MARRIED_TO]->(IreneP)
CREATE (IreneP)-[:MARRIED_TO]->(MarcoD)
CREATE (JaniceH)-[:LOVER]->(GothanD)
CREATE (GothanD)-[:LOVER]->(JaniceH)
CREATE (MagdelanaP)-[:FRIEND]->(MarcoD)
CREATE (MarcoD)-[:FRIEND]->(MagdelanaP)
CREATE (JaniceH)-[:FRIEND]->(MagdelanaP)
CREATE (MagdelanaP)-[:FRIEND]->(JaniceH)
CREATE (GothanD)-[:FRIEND]->(MarcoD)
CREATE (MarcoD)-[:FRIEND]->(GothanD);




--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages