Light
Dark
System
v4latest
v5dev
v4latest
v3
v2
v1

Indexes

This section describes the SDL declarations pertaining to indexes.

Declare an index for a “User” based on the “name” property:

Copy
type User {
    required name: str;
    address: str;

    multi friends: User;

    # define an index for User based on name
    index on (.name) {
        annotation title := 'User name index';
    }
}

Define a new index corresponding to the more explicit DDL commands.

index on ( index-expr )
[ except ( except-expr ) ]
[ "{" annotation-declarations "}" ] ;

This declaration defines a new index with the following options:

on ( index-expr )

The specific expression for which the index is made. Note also that <index-expr> itself has to be parenthesized.

except ( exception-expr )
An optional expression defining a condition to create exceptions

to the index. If <exception-expr> evaluates to true, the object is omitted from the index. If it evaluates to false or {}, it appears in the index.

The valid SDL sub-declarations are listed below:

annotation-declarations

Set index annotation to a given value.

Light
Dark
System

We use ChatGPT with additional context from our documentation to answer your questions. Not all answers will be accurate. Please join our Discord if you need more help.