Reputation: 9369
When you add an indexed node in py2neo 1.6.0, you have two options:
graph_db = neo4j.GraphDatabaseService("http://localhost:7474/db/data/")
Option 1:
index = graph_db.get_or_create_index('Myindex')
indexed_node = index.get_or_create('key', 'value', {node props})
Option 2:
index = graph_db.get_or_create_index('Myindex')
indexed_node = graph_db.get_or_create_indexed_node('Myindex', 'key', 'value', {node props})
I.e. you can add the node via the Index or via the GraphDatabaseService.
Does it make a difference which one I use? Or are these just wrappers for the same function?
Upvotes: 2
Views: 1084
Reputation: 4495
Both the options you show will achieve the same result and are almost idenitical. In Option 2, however, your first line is redundant. The graph_db.get_or_create_indexed_node
method is a shortcut that creates both the index (if it does not already exist) and the node in a single call.
Upvotes: 1