Tool Neo4j

Getting Started with Neo4j 

 

  1. Setting NEO4J

I.1 Setting  JDK:

we can download latest JDK version from Oracle homepage

(http://www.oracle.com/technetwork/java/javase/downloads/index.html)

 

I.2 Setting Neo4J:

– There are two versions for us to choose from: Community version for research, learning small projects (no license required) Enterprise version is a full option for large projects and requires many processing tasks. fast (need license). (http://neo4j.com/download/)

Neo4j’s address: https://neo4j.com 

Download neo4j for your platform ( ) as individuals

Your download will start automatically in a few minutes.

 

After downloading proceed to install and launch 

1 .Open Neo4j Desktop installer 

In your desktop, locate and double-click the Computer icon to start the installation.

2. Install Neo4j in desktop

Carry out the installation.

 

Click on the link below to open the web interface of neo4j, log in with the account neo4j/neo4j and change the new password for the systemSign in with your Google or social media account, or create a new email-based login.

Create and start a database

Click the new button.

This will turn into two blue buttons. Click on the one labeled, Create a local graph.

Enter the password of your choice in the Set Password field. Then, click the blue button labeled Create.

The “Create Application” button will soon be replaced by the “Start” button. Click it.

Open Neo4j browser

Once the database has started, click the “Manage” button.

Clicking the “Open Browser” button will appear in the Database Management area. The browser will open in a new window, as shown below.

 

So we are ready to design graph data already.

  • Neo4j Browser is a tool for developers to explore their Neo4j database, execute Cypher queries, and view the results in tabular or graph form. You can even use the Browser to:
  • Insert information
  • Calling User Defined Procedures in Java
  • Query Profile, look at the execution plan with EXPLAIN and PROFILE. 


Guide to test data movies 

  1. Download Data and extract it

  2. Create a data folder in the htdocs folder in xampp and then copy the data

extract

3.open app and run apache. Open neo4j and create new projects

4.Create one graph new and run it

5.Press start then access ‘localhost:7474/browser/’ to show the working screen

 

6.In the workbook: we run the comments line one by one

CREATE CONSTRAINT ON (m:Movie) ASSERT m.id IS UNIQUE;

CREATE CONSTRAINT ON (u:User) ASSERT u.id IS UNIQUE;

CREATE CONSTRAINT ON (g:Genre) ASSERT g.name IS UNIQUE;

7.Then run comment line

USING PERIODIC COMMIT LOAD CSV WITH HEADERS

FROM “http://localhost/data/movies.csv” AS line

WITH line, SPLIT(line.genres, “|”) AS Genres

CREATE (m:Movie { id: TOINTEGER(line.`movieId`), title: line.`title` })

WITH Genres

UNWIND RANGE(0, SIZE(Genres)-1) as i

MERGE (g:Genre {name: UPPER(Genres[i])})

CREATE (m)-[r:GENRE {position:i+1}]->(g);

Query user
Find all users

Find user with id = 21

 

Find what movies the user with id = 21 rated

Case Study

  • The question of this case study is that we have the movie “Toy Story” with id=1. We need to come up with a set of movies related to the movie “Toy Story”.
  •     Solutions :

– find episode U users who have rated the movie “Toy Story” with stars greater than 3

– find episode R of movies rated by U

– R rating according to the number of user reviews

Let’s take a look at the cypher queries that help solve the above problem

  • MATCH (n:Movie{id:1}) RETURN n : get movie toy story
  • MATCH (t:Movie{id:1})<-[r:RATING]-(u:User) WHERE r.rating>3 RETURN count(u) : get the number of users who rated the big toy story movie more than 3 stars
  • MATCH (t:Movie{id:1})<-[r:RATING]-(u:User)-[r2:RATING]->(t2:Movie) WHERE r.rating>3 AND r2.stars>3 RETURN t2.name,count(t2) ORDER BY count(t2) DESC LIMIT 25 : retrieve similar episodes based on user ratings 

 

 

Neo4j . data query command

 Command to create objects and relationships between objects: CREATE

Example: Create 02 subjects C# and ASP.NET MVC, C# is a conditional subject of ASP.NET MVC

Likewise for the ASP.NET MVC course, creating an ASP.NET relationship   requires a C# condition.

 Where MATCH is the command to find the alkali (we will learn later), to create a relationship, neo4j provides programmers with very natural commands:

 Find a c# course, find an ASP.NET course

Create a dependency ASP.NET relationship with c#.

Buy us some coffee

Thank You for your support as we work to give you the best of guides and articles.

 

Leave a Reply

Your email address will not be published.

top