1
votes

I am new to neo4j and py2neo. I have simple db where each node is a place eg. airport or railway station. I have added these as labels. There is also unique place_id as a property for each node. I want to get the node that corresponds some particular place_id but I dont know label.

I can do this if I know label :

graph.find_one("airport", "place_id", 413)

but I want to do something similar to:

graph.find_one("place_id", 413)

Also Do I need to create some Index? if yes then how ?

1

1 Answers

1
votes

You can use cypher to do what you want, but keep in mind that matching a node without specifying a label will fetch every node to check if property matches.

graph.cypher.execute("MATCH (place) where place.place_id=413 RETURN place")

To create indexes, everything you need is on py2neo documentation or you can create them using neo4j web interface