Create an index

Cassandra supports indexing any regular, non-primary key fields in an object type. Any field designated as a partition key or clustering column cannot be indexed, unless DataStax Enterprise is the defined database. A field will be indexed if @cql_index is added to the field definition. Indexed fields can be used as parameters in queries.

  • Reader type

type Reader @key @cql_entity(name: "reader") @cql_input {
 name: String! @cql_column(partitionKey: true)
 user_id: Uuid! @cql_column(clusteringOrder: ASC)
 birthdate: Date @cql_index(name: "date_idx")
 email: [String] @cql_column(typeHint: "set<varchar>")
 reviews: [Review] @cql_index(name: "review_idx", target: FULL)
 address: [Address]
}

The directive @cql_index has the following optional arguments:

Argument

Default

Description

name

Generated

Custom index name.

class

Secondary index

Custom index class, such as SAI.

target

VALUES

Specifies set and list index type. Options are FULL and VALUES.

options

N/A

Any options to pass to the underlying index query.