对Neo4j中索引和标签的困惑(py2neo)

时间:2014-10-29 17:05:49

标签: neo4j py2neo

我一直在努力了解Neo4j中旧索引和当前索引方案之间的区别,我无法理解是否确实需要使用graph_db.get_or_create_indexed_node。我有一个例子,如果有人能指出两种方法之间的区别,我将不胜感激。

使用指数:

patients = graph_db.get_or_create_index(neo4j.Node,"patients")
doctors=graph_db.get_or_create_index(neo4j.Node,"doctors")

p1 = graph_db.get_or_create_indexed_node("patients", "p1", "disease1", {"p1":"disease1", "gender" : "F"})

p2 = graph_db.get_or_create_indexed_node("patients", "p2", "disease2", {"p2":"disease2", "gender" : "M"})

p3 = graph_db.get_or_create_indexed_node("patients", "p3", "disease3", {"p3":"disease3", "gender" : "M","return":'yes'})

d1=graph_db.get_or_create_indexed_node("doctors","d1",{"years_experience":"20","re-admission_rate":"20%"})
d2=graph_db.get_or_create_indexed_node("doctors","d2",{"years_experience":"2","re-admission_rate":"40%"})

使用标签

patients=[{"patients", "p1", "disease1", {"p1":"disease1", "gender" : "F"}},{"patients", "p2", "disease2", {"p2":"disease2", "gender" : "M"}}]
doctors=[{"doctors","d1",{"years_experience":"20","re-admission_rate":"20%"}}]

for patient in patients:
    t=batch.create(patient)
    batch.add_labels(t,'Patient')
batch.submit()
batch.clear()

另外,如果我想批量添加关系(假设患者1今天和一个月内访问了doctor1),我该怎么做?我是否添加了与时间戳作为标签的新关系?

0 个答案:

没有答案
相关问题