Skip to main content
Guide
Secondary indexes narrow node or edge sources by property. Index creation is asynchronous and includes existing data through a durable backfill. A backfill (of a secondary, text, or vector index) reads only the rows of its label, through the label’s membership set, so its time follows the label’s size rather than the graph’s.

Index families

A definition names the entity kind, label, and property, plus unique (node equality only) or the range direction. A label and property can hold one equality index and one range index, but not both range directions.

Create an equality index

The returned DDL receipt identifies the durable operation. A build is not listed as an active index until it succeeds, so poll its operation_id before depending on indexed performance.

Track an index operation

status is queued, running, blocked, succeeded, or aborted. A blocked operation carries a blocker_code and does not resume on its own. Fix the cause, then run retry_index_operation (retryIndexOperation) as a write with the same operation_id, or abort_index_operation (abortIndexOperation) to discard the build. Repeating the same CREATE: The two failures apply even with createIndexIfNotExists.

Which predicates use an index

Only a label-scoped source reads an index: nWithLabelWhere("User", SourcePredicate.eq("status", "active")) (or the language-equivalent builder), or a .where(...) directly after nWithLabel("User"). A source predicate without a label scans every node.
  • and intersects the index reads of its indexable parts and tests the rest row by row.
  • or uses indexes only when every branch is indexable, and only one or per and.
  • A range index also serves orderBy without sorting; see Ordering and pagination.
  • A .where(...) after a traversal step, such as out("FOLLOWS"), with eq or isIn on an equality-indexed node property reads the matching IDs from the index once per request and checks each streamed node against them. Range predicates and eq(property, null) there are tested row by row.
Cypher and SQL statements use these indexes automatically, without naming them. An equality or IN match on a labeled node reads an equality index, and range comparisons and ordered LIMIT reads use a range index:
Explain the statement to see which index the plan reads. See Cypher indexes and performance for the conditions that keep an index in use. On a server, GET /v2/diagnostics lists recent queries that need an index (queries.missing_indexes) and unbounded scans (queries.unbounded_scans).

Range indexes

Create an ascending range index on Post.created_at:
Use nodeRangeDesc / node_range_desc (NodeRangeDescIndex in Go) for a descending index, and edgeRange / edge_range (EdgeRangeIndex) for edges. Native queries read an ascending index backwards for a descending sort; Cypher and SQL read only in the index’s direction, so match their ORDER BY.

Indexed values

Numbers sort before date-times, and date-times before strings. A rejected value fails the write, and existing rows holding one block a build. eq(property, null) scans the label.

Unique indexes

Create one with nodeUniqueEquality / node_unique_equality (NodeUniqueEqualityIndex in Go). Any number of nodes may have the property missing, null, or NaN, since those are not indexed. A unique index checks writes from the moment its build starts: a write that would duplicate a value the index already holds fails with unique_constraint_violation, before and after the index activates. A duplicate of a row the backfill has not reached yet is not visible to that check, so the backfill becomes blocked when it reaches the pair, as it does if existing data contains duplicates. Writes stay checked while it is blocked; fix the source data, then retry the same operation instead of creating a new definition.

Next steps

Troubleshoot index operations

Resolve blocked builds and lifecycle errors.

Filtering

Match predicates to source and post-traversal filters.