This section provides an overview of what neo4j is, and why a developer might want to use it.
It should also mention any large subjects within neo4j, and link out to the related topics. Since the Documentation for neo4j is new, you may need to create initial versions of those related topics.
This is the Cypher, Neo4j's query language. In many ways, Cypher is similar to SQL if you are familiar with it, except SQL refers to items stored in a table while Cypher refers to items stored in a graph.
First, we should start out by learning how to create a graph and add relationships, since that is essentially what Neo4j is all about.
CREATE (ab:Object { age: 30, destination: "England", weight: 99 })
Next, we will learn about finding MATCHes
MATCH (abc:Object) WHERE abc.destination = "England" RETURN abc;
MATCH specifies that you want to search for a certain node/relationship pattern (abc:Object) refers to one node Pattern (with label Object) which store the matches in the variable abc. You can think of this entire line as the following
abc = find the matches that is an Object WHERE the destination is England.
In this case, WHERE adds a constraint which is that the destination must be England. You must include a return at the end for all MATCH queries (neo4j will not accept just a Match...your query must always return some value [this also depends on what type of query you are writing...we will talk more about this later as we introduce the other types of queries you can make].
The next line will be explained in the future, after we go over some more elements of the Cypher Query Language. This is to give you a taste of what we can do with this language! Below, you will find an example which gets the cast of movies whose title starts with 'T'
MATCH (actor:Person)-[:ACTED_IN]->(movie:Movie)
WHERE movie.title STARTS WITH "T"
RETURN movie.title AS title, collect(actor.name) AS cast
ORDER BY title ASC LIMIT 10;
A complete list of commands and their syntax can be found at the official Neo4j Cypher Reference Card here.
Prerequisite steps:
/bin
of the extracted folder and execute in terminal
./neo4j console
./neo4j start
Each Neo4j server currently (in the community edition) can host a single Neo4j database, so in order to setup a new database:
/bin
and execute ./neo4j stop
to stop the server/conf
and edit the file neo4j.conf
, changing the value of the parameter dbms.active_database
to the name of the new database that you want to create../neo4j start
/data/databases
, under a folder with the name specified in the parameter dbms.active_database
.Make sure the Neo4j server is not running; go to sub-directory /bin and execute ./neo4j status
. If the output message shows that the server is running, also execute ./neo4j stop
.
Then go to sub-directory /data/databases and delete the folder of the database you want to remove.
Go to Install Neo4j which should detect the OS platform via your web browser, download and follow the usual installation instructions for your OS.
Neo4j was created with Java, therefore will run on any platform with Java installed, however the Neo4j team has simplified installation by providing easy installation packages for popular platform (e.g. a .dmg for Mac, a .deb for Debian and Ubuntu, an .exe for Windows 64 and 32 bit platforms...).
To review other versions and platforms available, see Other Neo4j Releases Page
Setup Neo4j as a Docker container :
## Required : Docker machine, docker cli
# Pull neo4j image from the docker hub
docker pull neo4j
# create the docker container
docker run \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
neo4j
# If you are running docker directly on the host (e.g ubuntu, RHEL, CentOs etc)
# Access the neo4j console at http://localhost:7474
# If you are on OSX/ Windows
# Access the neo4j console at http://<docker-machine-ip>:7474
RDBMS | Graph Database |
---|---|
Tables | Graphs |
Rows | Nodes |
Columns and Data | Properties and its values |
Constraints | Relationships |
Joins | Traversal |