# Neo4j Features and Practical Usage
⚡ "Even in a graph DB, index design is 80% of performance." Put the right index on your MATCH anchor property and lookups go from O(n) to O(log n).
🏷️ Title: Range / Text / Point / Composite index
🔗 URL:
📘 Overview
An index is a copy of nodes, relationships, or properties that provides a fast access path to the primary data. Once created, the DBMS keeps it updated automatically. It speeds up the anchor (starting point) of a MATCH, and the Cypher planner selects it automatically based on the predicate.
⚙️ How It Works
・Range (default): solves the most predicates—equality, range comparisons, `IN`, and `STARTS WITH`. This is the first index to reach for.
・Text: `STRING`-only, optimized for `CONTAINS` and `ENDS WITH`—ideal for substring search screens.
・Point: for spatial `POINT` values, optimized for distance queries and bounding-box searches.
・Composite: indexes several properties together, solving multi-condition filters in one go.
・Token lookup: a foundational index that speeds up label / relationship-type lookups.
・Beyond these, full-text indexes and vector indexes (similarity search / GenAI) are also available.
🛠️ Practical Usage
Creating range / composite / text / point indexes on anchor properties:
```cypher
CREATE INDEX user_email IF NOT EXISTS
FOR (u:User) ON (
CREATE INDEX order_composite IF NOT EXISTS
FOR (o:Order) ON (o.customerId, o.status);
CREATE TEXT INDEX product_name_text IF NOT EXISTS
FOR (p:Product) ON (
CREATE POINT INDEX store_loc IF NOT EXISTS
FOR (s:Store) ON (s.location);
```
Inspect and drop them:
```cypher
SHOW INDEXES;
DROP INDEX user_email IF EXISTS;
```
💡 Use Cases
・Apps that anchor MATCH on ` `Order.orderId`, or `Product.sku`, making lookups O(log n).
・Search screens that pick range for `STARTS WITH`, text for `CONTAINS`/`ENDS WITH`, and point for geo queries.
⚠️ Caveats
・Which index applies depends on the predicate. `CONTAINS` is not served by a range index—it needs a text index.
・Indexes add write cost and storage. Confirm they are actually used with `PROFILE` before relying on them.
・Composite indexes apply from the leading property onward, so column order affects performance.
#
Neo4j# #
Cypher#