Indexes can be configured on one or more fields in order to improve speed of data retrieval, or defining uniqueness.
Note that for setting a single field as unique, use the
method on the field builder as follows:
Indexes can be configured on composition of fields and edges. The main use-case is setting uniqueness on fields under a specific relation. Let's take an example:
In the example above, we have a
City with many
Streets, and we want to set the
street name to be unique under each city.
The full example exists in GitHub.
Edges columns are always added after
Fields columns. However, some indexes require these columns to come first in order to achieve specific optimizations. You can work around this problem by making use of Edge Fields.
Indexes currently support only SQL dialects, and do not support Gremlin. Dialect specific features are allowed using annotations. For example, in order to use index prefixes in MySQL, use the following configuration:
The code above generates the following SQL statements: