Skip to main content
Guide
A substring index stores the three-character windows (trigrams) of one String property, or of every String property, on the nodes or edges of a label. Filters that look for text inside a value, such as contains, grep, matches and Cypher =~, can then read the records that might match instead of scanning every record of the label. Results stay exact. The index only proposes candidates, and every candidate is checked against the original filter, so a query returns the same rows with or without the index.

Create a substring index

Use edge_substring (edgeSubstring, EdgeSubstringIndex) for an edge label, and drop either with drop_index and the same spec. The index builds in the background, like every index; its operation status reports the family substring.

Index every String property

One all-strings index serves text filters on any String property of the label, including properties that only appear in later writes. Use it when queries search several properties, or any of them.
The edge forms are edge_substring_all_strings, edgeSubstringAllStrings and EdgeSubstringAllStringsIndex. A label can have both kinds: a property’s own index serves filters on that property, because it holds only that property’s text, and the all-strings index serves every other property. To search for one pattern in any String property, combine one condition per property with OR. Conditions with the same pattern read the index once:

Index the prefilter properties too

Queries usually narrow by equality before they search text, for example by tenant and application. Create equality indexes on those properties as well. The substring index then checks only candidates inside the records the equality indexes select. Without them the equality conditions are evaluated row by row, which is still exact but slower.

Indexed values

  • Only String values are indexed. Other values, DateTime included, are skipped and never fail a write.
  • A write that stores more than 4 MiB of text in one indexed property fails. With an all-strings index every String property counts on its own, so several properties may hold more than 4 MiB together.
  • An all-strings index skips properties whose names start with $.
  • A filter on a dotted path such as meta.title reads a value nested in an object, which no substring index holds, so it scans the records instead.

Storage version

Creating the first substring index moves the database’s index storage format from version 8 to version 9, in the same commit that creates the index. A database without a substring index stays at version 8. Version 9 is one-way: releases that support at most version 8 refuse to open the database, and dropping every substring index does not move it back. Upgrade every reader before you create the first substring index.

Next steps

Filtering

Combine text conditions with equality and range conditions.

Secondary indexes

Index the equality properties your queries filter on.

Text indexes

Rank records by keyword relevance instead of matching text exactly.

Troubleshoot index operations

Resolve blocked builds and lifecycle errors.