neo4j(3)Setup neo4j Server and Know Concepts

chyeers 2014-08-19

neo4j(3)Setup neo4j Server and Know Concepts

1. Installation
Fetch and unzip the latest files
>wget http://dist.neo4j.org/neo4j-community-2.1.3-unix.tar.gz

Follow the README.txt file and place the zip package in working directory.

Open the working console
>bin/neo4j console

In the browser, visit this page
http://localhost:7474

For the REST Interface
http://localhost:7474/db/data/

2. Concept
Nodes 
Data is stored as Properties (Simple name/value pairs, Properties can be strings, numbers, or booleans)
Labels (A node can have zero or more labels, no properties for label)
Relationships (describe how the records are related; always have direction, type;)
Relationship Properties

3. Cypher
Create a node with properties
create (ee:Person {name:"Emil",from:"Sweden",klout:99})
create - is the key word to create data
() to indicate a node
ee:Person - a variable ‘ee’ and label ‘Person’ for the new node
{} - properties for the node

Match
match (ee:Person) where ee.name = "Emil" return ee;
match - keyword for a pattern

Create Relationship
(ee)-[:KNOWS { since: 2001} ] -> (js)
(ee)-[:KNOWS {rating: 5}] ->(ir)
(js)-[:KNOWS]->(ir)
…snip…

KNOWS is a name for the relationship, Person is the label for type of nodes.

Pattern Matching
MATCH (ee:Person)-[:KNOWS]-(friends)
WHERE ee.name = “Emil” RETURN ee, friends

(friends) will be bound to Emil’s friends.

Recommend Using Patterns
match (js:Person)-[:KNOWS]-()-[:KNOWS]-(surfer) where js.name = "Johan" AND surfer.hobby = "surfing" RETURN DISTINCT surfer

Find from Johan’s friends’s friends whose hobby is “surfing”


References:
http://www.hascode.com/2012/01/neo4j-graph-database-tutorial-how-to-build-a-route-planner-and-other-examples/
http://stackoverflow.com/questions/14814124/get-all-routes-between-two-nodes-neo4j

official website
http://www.neo4j.org/download

all clients
http://neo4j.com/contrib/
http://docs.neo4j.org/chunked/stable/tutorials-java-embedded.html
https://github.com/neo4j-contrib/java-rest-binding
http://docs.neo4j.org/chunked/milestone/rest-api.html
https://github.com/AnormCypher/AnormCypher

Installation
http://neo4j.com/docs/2.1.3/server-installation/#osx-install

scala client
https://github.com/AnormCypher/AnormCypher

tips
http://www.cnblogs.com/ljhero/archive/2012/05/13/2498039.html

I used to reading some documents
http://sillycat.iteye.com/blog/1551278
http://sillycat.iteye.com/blog/1551281

google cayley
https://github.com/google/cayley

相关推荐