Indexes overview¶
An index is a data structure that speeds up queries by providing quick access to specific data.
GQL supports the following types of indexes:
| Index type | Main purpose | Creation method |
|---|---|---|
| Primary key index | Quickly retrieve specific nodes. | Automatically created when the primary key is defined |
| Type index | Quickly find specific node types or edge types. | Automatically created |
| Normal index | Quickly retrieve nodes or edges based on one or more properties. | CREATE NORMAL INDEX |
| Vertex-centric index | Quickly locate associated edges centered on a node. Suitable for edge filtering on super nodes. A special usage of normal indexes. | Vertex-centric index |
| Vector index | Quickly find similar vectors. | CREATE VECTOR INDEX |
| Spatial index | Quickly retrieve spatial data. | CREATE SPATIAL INDEX |
| Full-text index | Quickly search for specific words or phrases within STRING properties. |
CREATE FULLTEXT INDEX |
Property value types and index support¶
The following table shows whether each property value type can be used to form a primary key and which explicitly created property indexes it supports. ✅ indicates supported, and ❌ indicates not supported. Primary key indexes are created automatically. Type indexes apply to node and edge types rather than property values and are therefore not included in the table.
| Property value type | Can be a primary key | Normal index (including vertex-centric indexes) | Vector index | Spatial index | Full-text index |
|---|---|---|---|---|---|
| Numeric | ✅ | ✅ | ❌ | ❌ | ❌ |
STRING |
✅ | ✅ | ❌ | ❌ | ✅ |
| Boolean | ✅ | ✅ | ❌ | ❌ | ❌ |
| Temporal instant types | ✅ | ✅ | ❌ | ❌ | ❌ |
DURATION |
✅ | ❌ | ❌ | ❌ | ❌ |
VECTOR |
❌ | ❌ | ✅ | ❌ | ❌ |
GEOGRAPHY |
❌ | ❌ | ❌ | ✅ | ❌ |
LIST |
❌ | ❌ | ❌ | ❌ | ❌ |
SET and MAP |
❌ | ❌ | ❌ | ❌ | ❌ |
Note
LIST,SET,MAP,VECTOR, andGEOGRAPHYproperties cannot be used to form a primary key. For all primary key constraints, see PRIMARY KEY.- Although normal indexes do not support
VECTORorGEOGRAPHYproperties, you can create vector indexes onVECTORproperties and spatial indexes onGEOGRAPHYproperties. DURATION,LIST,SET, andMAPproperties do not support any currently available explicitly created property index.NODE,EDGE,PATH,RECORD,TABLE, andNULLcannot be used as node or edge property types and therefore do not apply to this table.
Caution
SET and MAP cannot currently be used in a primary key. A graph type definition may not reject them, but writing nodes with such a primary key is not supported.
Apart from creating indexes, GQL also provides the following statements and commands to manage indexes:
- DROP INDEX: Deletes indexes.
- SHOW (ALL) INDEXES: Lists indexes.