Skip to content

08 Adding, updating nodes and links using Neo4j

Philippe Duke edited this page Feb 3, 2016 · 1 revision

Neo4j adding nodes and links

To add nodes and links, you should use Cypher queries (API still in development, sorry). Information about Cypher query language is available from neo4j manual:

http://neo4j.com/docs/stable/cypher-introduction.html

http://neo4j.com/docs/stable/cypher-getting-started.html

http://neo4j.com/docs/stable/cypher-query-lang.html

Information about all visible attributes is available in "Neo4j Node and Relationship properties". To execute query, run neo4j-shell utility. Example queries to make node and links.

$ cypher  
CREATE (n:NetAssistNode {name: 'naic.29632.as', ip_address: '205.162.49.41', icinga_name: 'netgraphz2 server'}) RETURN n;

$ cypher
MATCH (n:NetAssistNode), (m:NetAssistNode) WHERE n.name='sw-core-1g' AND m.name='netgraphz2 server' CREATE (n)-[r:LINKS_TO]->(m) RETURN r;

$ cypher
MATCH (n:NetAssistNode), (m:NetAssistNode) WHERE n.name='sw-core-1g' AND m.name='netgraphz2 server' CREATE (m)-[r:LINKS_TO]->(n) RETURN r;

This set of queries would create node with single attribute name (value 'netgraphz2 server') and link it to existing node with name 'sw-core-1g' (if such node exists).