Adding nodes to the graph is pretty simple,graph.merge_one is important as it prevents duplicate items. (If you run the script twice, then the second time it would update the title and not create new nodes for the same articles)
timestamp should be an integer and not a date string as neo4j doesnt really have a date datatype. This causes sorting issues when you store date as '05-06-1989'
article.push() is an the call that actually commits the operation into neo4j. Dont forget this step.
Adding Relationships to Neo4j Graph
create_unique is important for avoiding duplicates. But otherwise its a pretty straightforward operation.
The relationship name is also important as you would use it in advanced cases.
Cypher Query Samples
Count articles connected to a particular person over time
Search for other People / Locations connected to the same news articles as Trump with at least 5 total relationship nodes.
Importing and Authenticating
You have to make sure your Neo4j Database exists at localhost:7474 with the appropriate credentials.
the graph object is your interface to the neo4j instance in the rest of your python code. Rather thank making this a global variable, you should keep it in a class's __init__ method.
Query 1 : Autocomplete on News Titles
This is a sample cypher query to get all nodes with the property name that starts with the argument text.
Query 2 : Get News Articles by Location on a particular date
You can use this query to find all news articles (n) connected to a location (l) by a relationship.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0