Neo4j – Unwind Clause

Neo4j – Unwind Clause ”; Previous Next The unwind clause is used to unwind a list into a sequence of rows. Example Following is a sample Cypher Query which unwinds a list. UNWIND [a, b, c, d] AS x RETURN x To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Print Page Previous Next Advertisements ”;

Neo4j – Backup & Restore

Neo4j – Backup & Restore ”; Previous Next In real-time applications, we should take backup of our application database regularly, so that we can restore to some working condition at any failure point. This rule is applicable for both RDBMS and NoSQL databases. In this section, we are going to discuss about two important DBA tasks. How to back up a Neo4j Database. How to restore Neo4j Database to a specific backup. Note − These steps are applicable to Windows Operating System only. We should use similar kind of commands to do the same steps in other operating systems. Neo4j Database Backup Step 1 − Click “Neo4j Community” using the following path − Windows “Start” button → “All Programs” → “Neo4j Community” → “Neo4j Community” By default, it selects c:Users[username]DocumentsNeo4jdefault.graphdb. However if we wish to, we can change the path to a different directory. Step 2 − Here we have changed to our Neo4j Database folder. C:Ne04j2.0db Step 3 − Click the “Start” button. Once the server starts, we can observe our Neo4j Database files are generated at a specified directory. Before taking a database backup, the first and foremost thing we should do is shutdown the Neo4j Database server. Step 4 − Click the “Stop” button to shut down the server. Neo4j Database files are available at C:Ne04j2.0db Step 5 − Open the command prompt. Step 6 − Create a folder “Neo4jDbBackup-01” at C:Neo4j (This may be any location in your file system). mkdir C:Neo4jNeo4jDbBackup-01 It creates a new folder “Neo4jDbBackup-01” at the specified file system location “C:Neo4j” Step 7 − Type the following command and press Enter key. copy C:Ne04j2.0db C:Neo4jNeo4jDbBackup-01 This means our files are copied to the required destination folder. Access that folder and observe that the folder has our database files. Step 8 − Use any Windows compression/decompression tool like WinZip, 7 Zip, or WinRAR to zip our Database folder. Step 9 − Now our Neo4jDbBackup-01.zip file is created. If you have any memory constraints in your file system, then remove “Neo4jDbBackup-01” folder at “C:Neo4j” Neo4j Database Restore Step 1 − Shutdown the database server. Please refer to the previous steps to shut down the server. Step 2 − Empty the current database folder. Step 3 − Use any Windows compression/decompression tool like WinZip, 7 Zip, or WinRar to unzip our backup folder. Step 4 − Open the command prompt and execute the following command. Copy C:Neo4jNeo4jDbBackup-01 C:Ne04j2.0db Now we can observe that our database folder contains working backup files Step 5 − Start the server by clicking the “Start” button. Step 6 − Execute some MATCH + RETURN commands to verify whether we have restored our database properly. Print Page Previous Next Advertisements ”;

Neo4j – Return Clause

Neo4j – Return Clause ”; Previous Next The RETURN clause is used return nodes, relationships, and properties in Neo4j. In this chapter, we are going to learn how to − Return nodes Return multiple nodes Return relationships Return properties Return all elements Return a variable with column alias Returning Nodes You can return a node using the RETURN clause. Syntax Following is a syntax to return nodes using the RETURN clause. Create (node:label {properties}) RETURN node Example Before proceeding with the example, create 3 nodes and 2 relationships as shown below. Create (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) CREATE (Ind:Country {name: “India”, result: “Winners”}) CREATE (CT2013:Tornament {name: “ICC Champions Trophy 2013”}) CREATE (Ind)-[r1:WINNERS_OF {NRR:0.938 ,pts:6}]->(CT2013) CREATE(Dhoni)-[r2:CAPTAIN_OF]->(Ind) Following is a sample Cypher Query which creates a node named Dhoni and returns it. Create (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) RETURN Dhoni To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Returning Multiple Nodes You can also return multiple nodes using the return clause. Syntax Following is the syntax to return multiple nodes using the return clause. CREATE (Ind:Country {name: “India”, result: “Winners”}) CREATE (CT2013:Tornament {name: “ICC Champions Trophy 2013”}) RETURN Ind, CT2013 Example Following is a sample Cypher Query to return multiple nodes using the return clause. CREATE (Ind:Country {name: “India”, result: “Winners”}) CREATE (CT2013:Tornament {name: “ICC Champions Trophy 2013”}) RETURN Ind, CT2013 To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Here you can observe that Neo4j returned 2 nodes. Returning Relationships You can also return relationships using the Return clause. Syntax Following is the syntax to return relationships using the RETURN clause. CREATE (node1)-[Relationship:Relationship_type]->(node2) RETURN Relationship Example Following is a sample Cypher Query which creates two relationships and returns them. CREATE (Ind)-[r1:WINNERS_OF {NRR:0.938 ,pts:6}]->(CT2013) CREATE(Dhoni)-[r2:CAPTAIN_OF]->(Ind) RETURN r1, r2 To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Returning Properties You can also return properties using the RETURN clause. Syntax Following is a syntax to return properties using the RETURN clause. Match (node:label {properties . . . . . . . . . . }) Return node.property Example Following is a sample Cypher Query to return the properties of a node. Match (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) Return Dhoni.name, Dhoni.POB To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Returning All Elements You can return all the elements in the Neo4j database using the RETURN clause. Example Following is an example Cypher Query to return all the elements in the database. Match p = (n {name: “India”, result: “Winners”})-[r]-(x) RETURN * To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Returning a Variable With a Column Alias You can return a particular column with alias using RETURN clause in Neo4j. Example Following is a sample Cypher Query which returns the column POB as Place Of Birth. Match (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) Return Dhoni.POB as Place Of Birth To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Print Page Previous Next Advertisements ”;

Neo4j – Remove Clause

Neo4j – Remove Clause ”; Previous Next The REMOVE clause is used to remove properties and labels from graph elements (Nodes or Relationships). The main difference between Neo4j CQL DELETE and REMOVE commands is − DELETE operation is used to delete nodes and associated relationships. REMOVE operation is used to remove labels and properties. Removing a Property You can remove a property of a node using MATCH along with the REMOVE clause. Syntax Following is the syntax to remove a property of a node using the REMOVE clause. MATCH (node:label{properties . . . . . . . }) REMOVE node.property RETURN node Example Before proceeding with the example, create a node named Dhoni as shown below. CREATE (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) Following is a sample Cypher Query to remove the above created node using the REMOVE clause. MATCH (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) REMOVE Dhoni.POB RETURN Dhoni To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Here, you can observe that the node named POB was deleted. Removing a Label From a Node Similar to property, you can also remove a label from an existing node using the remove clause. Syntax Following is the syntax to remove a label from a node. MATCH (node:label {properties . . . . . . . . . . . }) REMOVE node:label RETURN node Example Following is a sample Cypher Query to remove a label from an existing node using the remove clause. MATCH (Dhoni:player {name: “MahendraSingh Dhoni”, YOB: 1981, POB: “Ranchi”}) REMOVE Dhoni:player RETURN Dhoni To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Here, you can observe that the label was deleted from the node. Removing Multiple Labels You can also remove multiple labels from an existing node. Syntax Following is the syntax to remove multiple labels from a node. MATCH (node:label1:label2 {properties . . . . . . . . }) REMOVE node:label1:label2 RETURN node Example Before proceeding with the example, create a node Ishant as shown below. CREATE (Ishant:player:person {name: “Ishant Sharma”, YOB: 1988, POB: “Delhi”}) Following is a sample Cypher Query to remove multiple labels from a node. MATCH (Ishant:player:person {name: “Ishant Sharma”, YOB: 1988, POB: “Delhi”}) REMOVE Ishant:player:person RETURN Ishant To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Here, you can observe that the specified labels were deleted from the node. Print Page Previous Next Advertisements ”;

Neo4j – Foreach Clause

Neo4j – Foreach Clause ”; Previous Next The FOREACH clause is used to update data within a list whether components of a path, or result of aggregation. Syntax Following is the syntax of the FOREACH clause. MATCH p = (start node)-[*]->(end node) WHERE start.node = “node_name” AND end.node = “node_name” FOREACH (n IN nodes(p)| SET n.marked = TRUE) Example Before proceeding with the example, create a path p in Neo4j database as shown below. CREATE p = (Dhawan {name:”Shikar Dhawan”})-[:TOPSCORRER_OF]->(Ind{name: “India”})-[:WINNER_OF]->(CT2013{name: “Champions Trophy 2013”}) RETURN p Following is a sample Cypher Query which adds a property to all the nodes along the path using the FOREACH clause. MATCH p = (Dhawan)-[*]->(CT2013) WHERE Dhawan.name = “Shikar Dhawan” AND CT2013.name = “Champions Trophy 2013″ FOREACH (n IN nodes(p)| SET n.marked = TRUE) To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Verification To verify the creation of the node, type and execute the following query in the dollar prompt. MATCH (n) RETURN n This query returns all the nodes in the database (we will discuss this query in detail in the coming chapters). On executing, this query shows the created node as shown in the following screenshot. Print Page Previous Next Advertisements ”;

Neo4j – Optional Match Clause

Neo4j – Optional Match Clause ”; Previous Next The OPTIONAL MATCH clause is used to search for the pattern described in it, while using nulls for missing parts of the pattern. OPTIONAL MATCH is similar to the match clause, the only difference being it returns null as a result of the missing parts of the pattern. Syntax Following is the syntax of the OPTIONAL MATCH with relationship. MATCH (node:label {properties. . . . . . . . . . . . . .}) OPTIONAL MATCH (node)–>(x) RETURN x Example Following is a sample Cypher Query which tries to retrieve the relations from the node ICCT2013. Since there are no such nodes, it returns null. MATCH (a:Tornament {name: “ICC Champions Trophy 2013″}) OPTIONAL MATCH (a)–>(x) RETURN x To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Here you can observe that since there are no matches for the required pattern, Neo4j returned null. Print Page Previous Next Advertisements ”;

Neo4j – Delete Clause

Neo4j – Delete Clause ”; Previous Next You can delete nodes and relationships from a database using the DELETE clause. Deleting All Nodes and Relationships Following is the query to delete all the nodes and the relationships in the database using the DELETE clause. Query MATCH (n) DETACH DELETE n To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. This will delete all the nodes and relationships from your neo4j database and make it empty. Deleting a Particular Node To delete a particular node, you need to specify the details of the node in the place of “n” in the above query. Syntax Following is the syntax to delete a particular node from Neo4j using the DELETE clause. MATCH (node:label {properties . . . . . . . . . . }) DETACH DELETE node Example Before proceeding with the example, create a node “Ishant” in the Neo4j database as shown below. CREATE (Ishant:player {name: “Ishant Sharma”, YOB: 1988, POB: “Delhi”}) Following is a sample Cypher Query which deletes the above created node using the DELETE clause. MATCH (Ishant:player {name: “Ishant Sharma”, YOB: 1988, POB: “Delhi”}) DETACH DELETE Ishant To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Here you can observe that the specified node is deleted. Print Page Previous Next Advertisements ”;

Neo4j – Skip Clause

Neo4j – Skip Clause ”; Previous Next The SKIP clause is used to define from which row to start including the rows in the output. Example Before proceeding with the example, create 5 nodes as shown below. CREATE(Dhawan:player{name:”shikar Dhawan”, YOB: 1985, runs:363, country: “India”}) CREATE(Jonathan:player{name:”Jonathan Trott”, YOB:1981, runs:229, country:”South Africa”}) CREATE(Sangakkara:player{name:”Kumar Sangakkara”, YOB:1977, runs:222, country:”Srilanka”}) CREATE(Rohit:player{name:”Rohit Sharma”, YOB: 1987, runs:177, country:”India”}) CREATE(Virat:player{name:”Virat Kohli”, YOB: 1988, runs:176, country:”India”}) Following is a sample Cypher Query which returns all the nodes in the database skipping the first 3 nodes. MATCH (n) RETURN n.name, n.runs ORDER BY n.runs DESC SKIP 3 To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Skip Using Expression You can skip the records of a result using an expression. Example Following is a sample Cypher Query which uses the SKIP clause with an expression. MATCH (n) RETURN n.name, n.runs ORDER BY n.runs DESC SKIP toInt (2*rand())+ 1 Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Print Page Previous Next Advertisements ”;

Neo4j CQL – Introduction

Neo4j CQL – Introduction ”; Previous Next CQL stands for Cypher Query Language. Like Oracle Database has query language SQL, Neo4j has CQL as query language. Neo4j CQL Is a query language for Neo4j Graph Database. Is a declarative pattern-matching language. Follows SQL like syntax. Syntax is very simple and in human readable format. Like Oracle SQL Neo4j CQL has commands to perform Database operations. Neo4j CQL supports many clauses such as WHERE, ORDER BY, etc., to write very complex queries in an easy manner. Neo4j CQL supports some functions such as String, Aggregation. In addition to them, it also supports some Relationship Functions. Neo4j CQL Clauses Following are the read clauses of Neo4j Cypher Query Language − Sr.No Read Clauses Usage 1 MATCH This clause is used to search the data with a specified pattern. 2 OPTIONAL MATCH This is the same as match, the only difference being it can use nulls in case of missing parts of the pattern. 3 WHERE This clause id is used to add contents to the CQL queries. 4 START This clause is used to find the starting points through the legacy indexes. 5 LOAD CSV This clause is used to import data from CSV files. Following are the write clauses of Neo4j Cypher Query Language − Sr.No Write Clause Usage 1 CREATE This clause is used to create nodes, relationships, and properties. 2 MERGE This clause verifies whether the specified pattern exists in the graph. If not, it creates the pattern. 3 SET This clause is used to update labels on nodes, properties on nodes and relationships. 4 DELETE This clause is used to delete nodes and relationships or paths etc. from the graph. 5 REMOVE This clause is used to remove properties and elements from nodes and relationships. 6 FOREACH This class is used to update the data within a list. 7 CREATE UNIQUE Using the clauses CREATE and MATCH, you can get a unique pattern by matching the existing pattern and creating the missing one. 8 Importing CSV files with Cypher Using Load CSV you can import data from .csv files. Following are the general clauses of Neo4j Cypher Query Language − Sr.No General Clauses Usage 1 RETURN This clause is used to define what to include in the query result set. 2 ORDER BY This clause is used to arrange the output of a query in order. It is used along with the clauses RETURN or WITH. 3 LIMIT This clause is used to limit the rows in the result to a specific value. 4 SKIP This clause is used to define from which row to start including the rows in the output. 5 WITH This clause is used to chain the query parts together. 6 UNWIND This clause is used to expand a list into a sequence of rows. 7 UNION This clause is used to combine the result of multiple queries. 8 CALL This clause is used to invoke a procedure deployed in the database. Neo4j CQL Functions Following are the frequently used Neo4j CQL Functions − Sr.No CQL Functions Usage 1 String They are used to work with String literals. 2 Aggregation They are used to perform some aggregation operations on CQL Query results. 3 Relationship They are used to get details of relationships such as startnode, endnode, etc. We will discuss all Neo4j CQL commands, clauses and functions syntax, usage and examples in-detail in the subsequent chapters. Neo4j CQL Data Types These data types are similar to Java language. They are used to define properties of a node or a relationship. Neo4j CQL supports the following data types − Sr.No CQL Data Type Usage 1 Boolean It is used to represent Boolean literals: true, false. 2 byte It is used to represent 8-bit integers. 3 short It is used to represent 16-bit integers. 4 int It is used to represent 32-bit integers. 5 long It is used to represent 64-bit integers. 6 float It is used to represent 32-bit floating-point numbers. 7 double It is used to represent 64-bit floating-point numbers. 8 char It is used to represent 16-bit characters. 9 String It is used to represent Strings. CQL Operators Following are the list of operators supported by Neo4j Cypher Query language. Sr.No Type Operators 1 Mathematical +, -, *, /, %, ^ 2 Comparison +, <>, <, >, <=, >= 3 Boolean AND, OR, XOR, NOT 4 String + 5 List +, IN, [X], [X…..Y] 6 Regular Expression =- 7 String matching STARTS WITH, ENDS WITH, CONSTRAINTS Boolean Operators in Neo4j CQL Neo4j supports the following Boolean operators to use in Neo4j CQL WHERE clause to support multiple conditions. Sr.No Boolean Operators Description 1 AND It is a Neo4j CQL keyword to support AND operation. It is like SQL AND operator. 2 OR It is a Neo4j CQL keyword to support OR operation. It is like SQL AND operator. 3 NOT It is a Neo4j CQL keyword to support NOT operation. It is like SQL AND operator. 4 XOR It is a Neo4j CQL keyword to support XOR operation. It is like SQL AND operator. Comparison Operators in Neo4j CQL Neo4j supports the following Comparison operators to use in Neo4j CQL WHERE clause to support conditions. Sr.No Boolean Operators Description 1 = It is a Neo4j CQL “Equal To” operator. 2 < > It is a Neo4j CQL “Not Equal To” operator. 3 < It is a Neo4j CQL “Less Than” operator. 4 > It is a Neo4j CQL “Greater Than” operator. 5 <= It is a Neo4j CQL “Less Than Or Equal To” operator. 6 > = It is a Neo4j CQL “Greater Than Or Equal To” operator. Print Page Previous Next Advertisements ”;

Neo4j – Order By Clause

Neo4j – Order By Clause ”; Previous Next You can arrange the result data in order using the ORDER BY clause. Syntax Following is the syntax of the ORDER BY clause. MATCH (n) RETURN n.property1, n.property2 . . . . . . . . ORDER BY n.property Example Before proceeding with the example, create 5 nodes in Neo4j database as shown below. CREATE(Dhawan:player{name:”shikar Dhawan”, YOB: 1985, runs:363, country: “India”}) CREATE(Jonathan:player{name:”Jonathan Trott”, YOB:1981, runs:229, country:”South Africa”}) CREATE(Sangakkara:player{name:”Kumar Sangakkara”, YOB:1977, runs:222, country:”Srilanka”}) CREATE(Rohit:player{name:”Rohit Sharma”, YOB: 1987, runs:177, country:”India”}) CREATE(Virat:player{name:”Virat Kohli”, YOB: 1988, runs:176, country:”India”}) Following is a sample Cypher Query which returns the above created nodes in the order of the runs scored by the player using the ORDERBY clause. MATCH (n) RETURN n.name, n.runs ORDER BY n.runs To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Ordering Nodes by Multiple Properties You can arrange the nodes based on multiple properties using ORDEYBY clause. Syntax Following is the syntax to arrange nodes by multiple properties using the ORDERBY clause. MATCH (n) RETURN n ORDER BY n.age, n.name Example Following is a sample Cypher Query which arranges the nodes created earlier in this chapter based on the properties – runs and country. MATCH (n) RETURN n.name, n.runs, n.country ORDER BY n.runs, n.country To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Ordering Nodes by Descending Order You can arrange the nodes in a database in a descending order using the ORDERBY clause. Syntax Following is the syntax to arrange the nodes in a database. MATCH (n) RETURN n ORDER BY n.name DESC Example Following is a sample Cypher Query which arranges the nodes in a database in a descending order using the ORDERBY clause. MATCH (n) RETURN n.name, n.runs ORDER BY n.runs DESC To execute the above query, carry out the following steps − Step 1 − Open the Neo4j desktop App and start the Neo4j Server. Open the built-in browser app of Neo4j using the URL http://localhost:7474/ as shown in the following screenshot. Step 2 − Copy and paste the desired query in the dollar prompt and press the play button (to execute the query) highlighted in the following screenshot. Result On executing, you will get the following result. Print Page Previous Next Advertisements ”;