This is a creation in Article, where the information may have evolved or changed.
NEO4J Introduction
Neo4j是一个高性能的,NOSQL图形数据库,它将结构化数据存储在网络上而不是表中。它是一个嵌入式的、基于磁盘的、具备完全的事务特性的Java持久化引擎,但是它将结构化数据存储在网络(从数学角度叫做图)上而不是表中。Neo4j也可以被看作是一个高性能的图引擎,该引擎具有成熟数据库的所有特性。程序员工作在一个面向对象的、灵活的网络结构下而不是严格、静态的表中——但是他们可以享受到具备完全的事务特性、企业级的数据库的所有好处。
NEO4J installation (MAC)
Download
Download neo4j Community Edition, download the address below
http://neo4j.org/download
Download the DMG file directly because it is a Mac download
Run
Install neo4j Community Edition and open, configure run data store path, configure and click Start
Run. jpg
NEO4J Remote Visualization operation
Open the options, locate the. neo4j.conf, and uncomment the following code
dbms.connectors.default_listen_address=0.0.0.0
Browser Open
If the NEO4J remote visualization operation is configured for the third step, access to http://0.0.0.0:7474/browser/is not directly accessible http://localhost:7474/browser/.
Access address. jpg
neo4j use
Basic additions and deletions and changes
Inserts a node. Inserts a node for the person category, and this node has a property name with a property value of Andres
CREATE (n:Person {name : 'Andres'});
Insert Edges. Insert a forward edge of A to B, and the category of the Edge is follow
MATCH (a:Person),(b:Person) WHERE a.name = 'Node A' AND b.name = 'Node B' CREATE (a)-[r:Follow]->(b);
Update the node. Update the node for a person category and set the new name.
MATCH (n:Person { name: 'Andres' }) SET n.name = 'Taylor';
Deletes a node. Neo4j If a node has an edge attached to it, you cannot simply delete the node.
MATCH (n:Person { name:'Taylor' }) DETACH DELETE n;
Deletes an edge.
MATCH (a:Person)-[r:Follow]->(b:Person) WHERE a.name = 'Node A' AND b.name = 'Node B' DELETE r;
Query the shortest path.
MATCH (ms:Person { name:'Node A' }),(cs:Person { name:'Node B' }), p = shortestPath((ms)-[r:Follow]-(cs)) RETURN p;
Queries the relationship between two nodes.
MATCH (a:Person { name:'Node A' })-[r]->(b:Person { name:'Node B' }) RETURN type(r);
Queries all follower of a node.
MATCH (:Person { name:'Taylor' })-[r:Follow]->(Person) RETURN Person.name;
For detailed enquiry, please see
https://neo4j.com/docs/developer-manual/current/cypher/
-
Call neo4j (JAVA) through code, the detailed call code is as follows, driver, please Hucay URL download driver https://neo4j.com/developer/language-guides/
Create node through code
private static void Create () {Driver Driver = graphdatabase.driver ("bolt://10.1.43.73", Authtokens.basic ("neo4j", "1qaz2wsx")); Session session = Driver.session (); Session.run ("CREATE (A:book {name: ' HelloWorld '})"); Session.close (); Driver.close ();
Query node through code
private static void query () {Driver Driver = Graphdatabase.driver ("bolt:// LocalHost ", Authtokens.basic (" neo4j "," 123456 "));//call address, username and password Session session = Driver.session (); Statementresult result = Session.run ("MATCH (a:person) WHERE a.name = ' Andres ' RETURN a.name as name"); while (Result.hasnext ()) {Record record = Result.next (); System.out.println (Record.get ("name"). asstring ()); } session.close (); Driver.close (); }
Call NEO4J (GOLABG) through code, the detailed call code is as follows, driver ibid.
package main import ( "fmt" bolt "github.com/johnnadratowski/golang-neo4j-bolt-driver" ) func main() { driver := bolt.NewDriver() conn, err := driver.OpenNeo("bolt://localhost:7687") if err != nil { panic(err) } defer conn.Close() stmt, err := conn.PrepareNeo("CREATE (n:NODE {foo: {foo}, bar: {bar}})") if err != nil { panic(err) } result, err := stmt.ExecNeo(map[string]interface{}{"foo": 1, "bar": 2.2}) if err != nil { panic(err) } numResult, err := result.RowsAffected() if err != nil { panic(err) } fmt.Printf("CREATED ROWS: %d\n", numResult) // CREATED ROWS: 1 }
Reference
http://blog.csdn.net/dyllove98/article/details/8635965
Http://www.cnblogs.com/rubinorth/p/5853204.html
Http://static.helloworld114.com/pages/exception/1.html