Neo4j SQL supports Indexes on node or dating properties to improve the performance of the utility. We can create indexes on houses for all nodes, that have the identical label call.
We can use these listed columns on MATCH or WHERE or IN operator to enhance the execution of CQL command.
In this chapter, we will discuss how to −
- Create an Index
- Delete an Index
Creating an Index
Neo4j CQL affords "CREATE INDEX" command to create indexes on Node or Relationship houses.
Syntax
Following is the syntax to create an index in Neo4j.
CREATE INDEX ON:label (node)
Example
Before proceeding with the example, create a node Dhawan as shown beneath.
CREATE (Dhawan:player{name: "shikar Dhawan", YOB: 1995, POB: "Delhi"})
Following is a sample Cypher Query to create an index on the node Dhawan in Neo4j.
CREATE INDEX ON:player(Dhawan)
To execute the above question, perform the subsequent steps −
Step 1 − Open the Neo4j desktop App and begin the Neo4j Server. Open the integrated browser app of Neo4j the use of the URL http://localhost:7474/ as shown underneath.
Step 2 − Copy and paste the desired query within the dollar spark off and press the play button (to execute the question) highlighted within the following screenshot.
Result
On executing, you will get the subsequent end result.
Deleting an Index
Neo4j CQL provides a "DROP INDEX" command to drop an current index of a Node or Relationshis assets.
Syntax
Following is the syntax to create an index in Neo4j.
DROP INDEX ON:label(node)
Example
Following is a sample Cypher Query to create an index at the node named “Dhawan” in Neo4j.
DROP INDEX ON:player(Dhawan)
To execute the above query, carry out the subsequent steps −
Step 1 − Open the Neo4j computer App and begin the Neo4j Server. Open the built-in browser app of Neo4j the usage of the URL http://localhost:7474/ as shown inside the following screenshot.
Step 2 − Copy and paste the desired question inside the dollar prompt and press the play button (to execute the question) highlighted within the following screenshot.
Result
On executing, you'll get the following result.