/    /  Cassandra – Create Index

Cassandra – Create Index

Create Index command allows to create new index on the specified column for a table. Cassandra indexes the data during the execution of command and also the new data that is being inserted once after the creation of index.

Syntax:

CREATE CUSTOM INDEX index_name
ON keyspace_name.table_name ( column_name )
(USING class_name) (WITH OPTIONS = map)

Example:

CREATE TABLE LearningStore.users (
user_idint PRIMARY KEY,
created_date timestamp,
first_name text,
last_name text,
email text
);
CREATE INDEX email_idx ON LearningStore.users(email);
CREATE INDEX ON myschema.users (zip);