Tutorial by Examples

from py2neo import authenticate, Graph, Node, Relationship authenticate("localhost:7474", "neo4j", "<pass>") graph = Graph() You have to make sure your Neo4j Database exists at localhost:7474 with the appropriate credentials. the graph object is your interfa...
results = News.objects.todays_news() for r in results: article = graph.merge_one("NewsArticle", "news_id", r) article.properties["title"] = results[r]['news_title'] article.properties["timestamp"] = results[r]['news_timestamp'] article.pus...
results = News.objects.todays_news() for r in results: article = graph.merge_one("NewsArticle", "news_id", r) if 'LOCATION' in results[r].keys(): for loc in results[r]['LOCATION']: loc = graph.merge_one("Location", "name", loc)...
def get_autocomplete(text): query = """ start n = node(*) where n.name =~ '(?i)%s.*' return n.name,labels(n) limit 10; """ query = query % (text) obj = [] for res in graph.cypher.execute(query): # print res[0],res[1] obj.a...
def search_news_by_entity(location,timestamp): query = """ MATCH (n)-[]->(l) where l.name='%s' and n.timestamp='%s' RETURN n.news_id limit 10 """ query = query % (location,timestamp) news_ids = [] for res in graph.cypher.e...
Count articles connected to a particular person over time MATCH (n)-[]->(l) where l.name='Donald Trump' RETURN n.date,count(*) order by n.date Search for other People / Locations connected to the same news articles as Trump with at least 5 total relationship nodes. MATCH (n:NewsArticle)-[...

Page 1 of 1