2

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?

4

1 回答 1

1

您显示的两个选项都将达到相同的结果并且几乎相同。但是,在选项 2 中,您的第一行是多余的。该graph_db.get_or_create_indexed_node方法是在一次调用中创建索引(如果它不存在)和节点的快捷方式。

于 2013-09-17T09:43:37.693 回答