You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Indexes and constraints are essential for performance and data integrity in Neo4j. Indexes speed up queries by avoiding full graph scans, while constraints enforce rules about your data.
Without indexes, Neo4j must scan every node with a given label to find matches:
// Without an index, this scans ALL Person nodes
MATCH (p:Person {email: "alice@example.com"})
RETURN p
With an index on :Person(email), Neo4j goes directly to the matching node.
| Index Type | Purpose | Example |
|---|---|---|
| Range index | General-purpose lookups, ranges, sorting | Equality, >, <, STARTS WITH |
| Text index | Full-text string matching | CONTAINS, ENDS WITH |
| Point index | Geospatial queries | Distance and bounding-box queries |
| Composite index | Multi-property lookups | Queries filtering on multiple properties |
| Full-text index | Advanced text search with scoring | Fuzzy matching, relevance ranking |
| Lookup index | Internal label/type lookups | Automatic — do not create manually |
// Index on a single property
CREATE INDEX person_email FOR (p:Person) ON (p.email)
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.