Database Reference
In-Depth Information
Creating schema with Cypher
Let's create some indexes and constraints using Cypher on our movie dataset:
• Create the index on the property Name for all the nodes that have the Label
Artist :
CREATE index on :Artist(Name);
• Drop index which was created on :Artist(Name) :
DROP index on :Artist(Name);
• Create unique Constraint on :Movies(Title) :
CREATE Constraint on (movies:Movie) ASSERT
movies.Title IS UNIQUE;
• Drop unique Constraint on :Movies(Title) :
Drop Constraint on (movies:Movie) ASSERT movies.Title
IS UNIQUE;
• Query the status of all indexes and constraints within your database:
Schema
• Query the status of index : Artist(Name)
schema -l :Artist -p Name
In the preceding statement, -l will list all indexes on a given label. -p will list in-
dexes on a given property and -v is to print errors for the indexes that are in the
failed state.
• Forcing queries to use indexes:
MATCH (n:Artist)
USING INDEX n:Artist(Name)
WHERE n.Name = 'Sylvester Stallone' RETURN n;
Search WWH ::




Custom Search