Tables can contain partition keys and clustering keys, both of which define theprimary key. A table can also include non-primary keys.
If you wish to create a table query that uses anything other than the partition keyto define which row or rows are to be retrieved, a column index must be createdon each column to read the data.
Currently, those indexes can be created with REST,CQL, or GraphQL.
To use the REST API to create indexes, you'll need theapplication token you generatedto create other schema in your keyspace.
Send a POST request to /api/rest/v2/schemas/keyspaces/undefined/tables/undefined/indexes to create an index.Set the index definitions in the JSON body in the --data . In this example,an index name is defined as favbooksidx for the column favorite_books inthe keyspace users_keyspace and table users .An option to only create the index if it already exists is set with ifNotExists: true ;the default is false .
Two additional options are available:
- type can be defined to use SAI indexes if desired; the default is secondary indexes.
- kind defines the kind of index for map collections; the choices available are VALUES/KEYS/ENTRIES/FULL .
Here is an additional example, which creates indexes that are used in the REST API examples:
Note the use of the kind in the definitions used for the map collection evaluations .