neo4j - Cypher queries in py2neo -
i starting utilize py2neo , tried work on sample info sets. here (simplified) original set of queries:
create (ann:person{name:'ann',gender:'female'}) create (target:store{name:'target',location:'new york'}) create (ann)-[:purchased {amount:'100',status:'denied'}]->(target)
in py2neo tried this:
ann,=graph_db.create(node({name:'ann',gender:'female'})) ann.add_labels("person") target,=graph_db.create(node({name:'target',location:'new york'})) target.add_labels("merchant") (ann,"purchased",target,{'amount':'100', 'status':'denied'})
this query returns
(node('http://localhost:7474/db/data/node/0'), 'purchased', node('http://localhost:7474/db/data/node/3'), {'amount': '100', 'status': 'denied'})
i have lot of different users, wanted find of them transactions denied
query_string=""" match (customer:person)-[r:purchased]->(merchant) r.status = "denied" homecoming customer.name customer_name """
then seek execute it
result = neo4j.cypherquery(graph_db, query_string).execute()
it returns empty object. doing wrong?
i suggest, when creating node or relationship, utilize merge_one , create_unique respectively in order ensure won't create duplicates.
e.g:
x=graph.merge_one("boy","name",bname) y=graph.merge_one("girl","name",gname) likes=relationship(x, "likes", y) graph.create_unique(likes)
neo4j py2neo
No comments:
Post a Comment