NEO4J Installation & Getting Started & some pros and cons

Source: Internet
Author: User
Tags create index neo4j
1. Installation

On neo4j official website, download community version, click Install can. It's simple, nothing to say. 2. Getting Started

Since it is an introduction, start from the simple, step by step familiar with neo4j. 2.1 Graphical operator Interface

After running the neo4j, open the Web page in the browser: http://localhost:7474, you can enter the Neo4j graphical interface, in which the database is directly operational, you can also view the status of the database.

At the top of the page you can write cypher statements and run them. The right side shows some of the database's status and provides a subset of the operations, including: Database information. Database information. The node category, the category of the edge, attributes (including properties of the node and properties of the edge). Favorites. Write the basic database statements, including the creation of nodes, query the number of nodes, the number of edges and so on. Create a sample diagram. View the status of the database. Documentation. Various official documents. Neo4j Browser Sync. Clears the local database. Synchronize with the cloud database. Browser Settings. Graphical operator interface settings. 2.2 Cypher Basic Statement

Cypher is the database language of neo4j, get started words at least need to know and delete to change. 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 = ' Node A ' and = ' 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 = ' Taylor ';
Deletes the node and its attached edge. Neo4j If a node has an edge attached to it, you cannot simply delete the node.
MATCH (N:person {name: ' Andres '})
Deletes an edge.
MATCH (A:person)-[r:follow]-> (B:person)
WHERE = ' Andres ' and = ' Taylor '

Then is the query statement, as a graph database, definitely want to point out a different query right. Shortest path.

MATCH (Ms:person {name: ' Andres '}), (Cs:person {name: ' Taylor '}), p = Shortestpath ((ms)-[r:follow]-(CS)) RETURN p;
Queries the relationship between two nodes.
MATCH (A:person {name: ' Andres '})-[r]-> (B:person {name: ' Taylor '})
RETURN type (r);
Queries all follower of a node.
MATCH (:P erson {name: ' Taylor '})-[r:follow]-> (person)

There is more to see the official User manual: Official user manual 2.3 Creating a neo4j database

After running neo4j, you can select the database creation location in the Software window, and then neo4j automatically creates the database for us.

Creates a uniqueness constraint that has an index effect, similar to a primary key in a relational database. Note that this can only be set when the data is not yet inserted in the database.

Create an index.
CREATE INDEX on:P erson (name);
View all the nodes and the number of sides
MATCH (N) RETURN count (n);
MATCH ()--() RETURN count (*);

There is more to see the official User manual: Official user manual 2.4 neo4j driver

NEO4J provides a database driver for several languages, such as in Java, where you can insert a node:

Driver Driver = Graphdatabase.driver ("Bolt://localhost", Authtokens.basic ("neo4j", "neo4j"));
Session session = Driver.session (); ("CREATE (A:person {name: ' Arthur '})");

Session.close ();
Driver.close ();

Query node:

Driver Driver = Graphdatabase.driver ("Bolt://localhost", Authtokens.basic ("neo4j", "neo4j"));
Session session = Driver.session ();

Statementresult result = ("MATCH (a:person) WHERE = ' Arthur ' RETURN as name");
while (Result.hasnext ())
    record record = ();
    System.out.println (Record.get ("name"). asstring ());

Session.close ();
Driver.close ();
3. Pros and cons

Used a period of time neo4j, summed up the pros and cons I found.

Advantages: Data insertion, query operation is very intuitive, no longer like before to consider the relationship between the tables. The graph search and graph traversal methods provided are convenient and the speed is relatively fast.

Cons: The hardest thing to endure is the very slow insertion speed. This may be because you need to save some extra information (in order to query the service) when creating nodes and edges. Do not know is not my code problem, insert 10,000 nodes, 10,000 sides spent nearly 10 minutes ... Super-large nodes. When a node has a very long edge (common to large v), the speed of operations on the node will be greatly reduced. The problem was long overdue, and the authorities said they would deal with it, but it is still not satisfying. The most common way to improve database speed is to allocate more memory, but look at the official manual, seemingly unable to directly set the database memory consumption, but need to calculate after the "reserved" Memory ... 4. Applicable Scenarios

Due to its obvious advantages and disadvantages, NEO4J is suitable for storing "less modified, more queries, no super-large nodes" of the graph data.

In addition, for the disadvantage of neo4j, there is a database with mixed indexes Arangodb may be a good consideration. According to its official website, Arangodb not only has the advantages of general graphics database, but also leads the neo4j in the speed of various operations.

Reprint Address: Click to open the link

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.