I have been trying to understand the difference between old indexes and current indexing scheme in Neo4j and I have trouble understanding whether I actually need to use graph_db.get_or_create_indexed_node
or not. I have an example and I would appreciate if someone could point out what is the difference between 2 approaches.
USING INDEXES:
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%"})
USING LABELS
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()
Also, if I want to batch add relationships (let's say patient1 visits doctor1 today and in one month), how do I do that? Do I add new relationship with a timestamp as a label?